/** * Delete the record in DB by it struct * * @param $struct rad_struct * @param $tablename string * * @return integer number of deleted items */ public static function delete_struct(rad_struct $struct, $tablename) { $pr_key = $struct->getPrimaryKey(); if ($pr_key) { $res = self::$dbc->prepare('DELETE FROM ' . $tablename . ' WHERE `' . $pr_key . '`=?'); $res->execute(array($struct->{$pr_key})); if ($res and rad_config::getParam('cache.power', false)) { //rad_cacheutils::incTableVer($tablename); } return $res->rowCount(); } else { throw new rad_exception('Функция delete_struct работает ТОЛЬКО с теми структурами, у которых объявлен primary key как одно поле!'); $res = 0; return $res; } }