[*] Classes : improve performances of "Feature detachable" feature

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8754 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
aFolletete
2011-09-24 15:03:21 +00:00
parent cfca41b012
commit 78f6a4e20a
18 changed files with 334 additions and 149 deletions
+17
View File
@@ -905,4 +905,21 @@ abstract class ObjectModelCore
return isset($row['id']);
}
/**
* This method is allow to know if a entity is currently used
* @since 1.5.0.1
* @param string $table name of table linked to entity
* @param bool $has_active_column true if the table has an active column
* @return bool
*/
public static function isCurrentlyUsed($table, $has_active_column = false)
{
$query = new DbQuery();
$query->select('`id_'.pSQL($table).'`');
$query->from(pSQL($table));
if ($has_active_column)
$query->where('`active` = 1');
return (bool)Db::getInstance()->getValue($query);
}
}