execute($qr) && (trim($id_group) == '' || self::deleteActivity($id, $id_group)); } public static function deleteActivity($id, $table) { return Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'ets_rv_activity` WHERE `id_ets_rv_' . pSQL($table) . '`=' . (int)$id); } public static function getParent($id, $table, $parent) { if (!$id || !Validate::isUnsignedInt($id) || !$table || !$parent ) { return false; } $parent_id = 'id_' . trim($parent); $dq = new DbQuery(); $dq ->select('a.validate, a.' . $parent_id) ->from($parent, 'a') ->leftJoin(pSQL($table), 'b', 'a.' . $parent_id . '=b.' . $parent_id) ->where('id_' . pSQL($table) . '=' . $id); return Db::getInstance()->getRow($dq); } public static function getIds($table, $id_customer, $qa = 0, $answer = 0) { if (!$id_customer || !Validate::isUnsignedInt($id_customer) || !$table ) { return false; } $qd = new DbQuery(); $qd ->select('GROUP_CONCAT(id_' . pSQL($table) . ' SEPARATOR ",")') ->from($table) ->where('id_customer=' . (int)$id_customer) ->where('question=' . (int)$qa); if (trim($table) == 'ets_rv_comment' && $answer != -1) { $qd ->where('answer=' . (int)$answer); } return Db::getInstance()->getValue($qd); } public static function deleteByIds($table, $ids) { $qd = new DbQuery(); $qd ->type('DELETE') ->from($table) ->where('id_' . $table . ' IN (' . $ids . ')'); return Db::getInstance()->execute($qd); } public static function deleteGroupTables($tables, $parent_table, $where = null) { if (!$parent_table || !$tables || !is_array($tables) ) { return false; } $res = true; foreach ($tables as $table) { $res &= Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . pSQL($parent_table) . '_' . pSQL($table) . '`' . ($where != null ? ' WHERE ' . $where : '') . ';'); } return $res; } }