$item_categories_cur=$this->Conn->GetCol('SELECT CategoryId FROM '.$table.' WHERE ItemResourceId = '.$item_id);
$item_categories_live=$this->Application->IsTempTable($table)?$this->Conn->GetCol('SELECT CategoryId FROM '.$this->Application->GetLiveName($table).' WHERE ItemResourceId = '.$item_id):array();
if($duplicates_found||$has_page)// other category has same filename as ours OR we have filename, that ends with _number
{
$append=$duplicates_found?'_a':'';
if($has_page)
{
$filename=$rets[1].'_'.$rets[2];
$append=$rets[3]?$rets[3]:'_a';
}
// check live & temp table
$sql_cur='SELECT '.$id_field.' FROM '.$table.' WHERE (Filename = %s) AND ('.$id_field.' != '.$item_id.')'.$cat_filter;
$sql_live=$this->Application->IsTempTable($table)?'SELECT '.$id_field.' FROM '.$this->Application->GetLiveName($table).' WHERE (Filename = %s) AND ('.$id_field.' != '.$item_id.')'.$cat_filter:false;