added: item content type: raw

git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@549 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-01-11 14:47:52 +00:00
parent 59943c87cd
commit 3c95b84633
28 changed files with 319 additions and 178 deletions

View File

@@ -200,7 +200,7 @@ const char * Db::AssertValue(PGresult * r, int row, int col)
{
log << log1 << "Db: there is no such an item in the result, row:" << row << ", col:" << col << logend;
throw Error(Error::db_no_item);
throw Error(Error::no_item);
}
return res;
@@ -475,8 +475,8 @@ Error Db::AddItemIntoContent(Item & item)
AssertConnection();
std::ostringstream query;
query << "insert into core.content (content, content_type) values (";
query << '\'' << Escape(item.content) << "', ";
query << '\'' << item.content_type << "');";
query << '\'' << Escape(item.content) << "', ";
query << '\'' << static_cast<int>(item.content_type) << "');";
r = AssertQuery(query.str());
AssertResultStatus(r, PGRES_COMMAND_OK);
@@ -586,8 +586,8 @@ Error Db::EditItemInContent(Item & item)
std::ostringstream query;
query << "update core.content set (content, content_type) = (";
query << '\'' << Escape(item.content) << "', ";
query << '\'' << item.content_type << "' ";
query << '\'' << Escape(item.content) << "', ";
query << '\'' << static_cast<int>(item.content_type) << "' ";
query << ") where id='" << item.content_id << "';";
r = AssertQuery(query.str());
@@ -620,7 +620,7 @@ Error Db::EditItemGetId(Item & item)
AssertResultStatus(r, PGRES_TUPLES_OK);
if( PQntuples(r) != 1 || PQnfields(r) != 2 )
throw Error(Error::db_no_item);
throw Error(Error::no_item);
// we cannot use AssertColumn() with a name because both columns are called 'id'
item.id = atol( AssertValue(r, 0, 0) );
@@ -654,7 +654,7 @@ Error Db::EditItemGetContentId(Item & item)
AssertResultStatus(r, PGRES_TUPLES_OK);
if( PQntuples(r) != 1 || PQnfields(r) != 1 )
throw Error(Error::db_no_item);
throw Error(Error::no_item);
item.content_id = atol( AssertValue(r, 0, 0) );
}
@@ -735,7 +735,7 @@ Error Db::EditDefaultItem(long id, long new_default_item)
if( rows == 0 )
{
result = Error::db_no_item;
result = Error::no_item;
log << log1 << "Db: EditDefaultItem: no such item, id: " << id << logend;
}
}
@@ -918,7 +918,7 @@ Error Db::GetItem(long parent_id, const std::string & url, Item & item)
int rows = PQntuples(r);
if( rows == 0 )
throw Error(Error::db_no_item);
throw Error(Error::no_item);
ItemColumns col;
col.SetColumns(r);