changed: DirContainer - uses std::list instead of std::vector as the main container
we do not have to rebuild indexes after deleting some items added: DirContainer::DelById(long id) changed: Dirs::CheckRootDir() addes the root dir if there is no one added: Dirs::DeleteDir(long id) - deletes specified directory (and its contents) (from the cache and the database) added: Db::DelDirById(long id) - deletes a dir from the database and its first children added: standard function rm can delete directories git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@487 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
40
core/db.cpp
40
core/db.cpp
@@ -986,6 +986,46 @@ return result;
|
||||
|
||||
|
||||
|
||||
Error Db::DelDirById(long id)
|
||||
{
|
||||
Error result = Error::ok;
|
||||
PGresult * r = 0;
|
||||
const char * crows;
|
||||
|
||||
try
|
||||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query, query2;
|
||||
|
||||
query << "delete from core.content where content.id in (select content_id from core.item where parent_id='" << id << "');";
|
||||
r = AssertQuery( query.str() );
|
||||
AssertResultStatus(r, PGRES_COMMAND_OK);
|
||||
|
||||
crows = PQcmdTuples(r);
|
||||
if( crows )
|
||||
log << log2 << "Db: deleted " << atol(crows) << " rows from core.content" << logend;
|
||||
|
||||
query2 << "delete from core.item where id='" << id << "' or parent_id='" << id << "';";
|
||||
r = AssertQuery( query2.str() );
|
||||
AssertResultStatus(r, PGRES_COMMAND_OK);
|
||||
|
||||
crows = PQcmdTuples(r);
|
||||
if( crows )
|
||||
log << log1 << "Db: deleted dir: " << id << " (deleted: " << atol(crows) << " rows)" << logend;
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
result = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Db::DelItemDelItem(const Item & item)
|
||||
{
|
||||
|
Reference in New Issue
Block a user