/** * Inserts the item! * @return integer number of inserted rows (as usually 1) */ public function insert() { $pk = $this->getPrimaryKey(); if ($rows = rad_dbpdo::insert_struct($this, $this->_getTableName())) { $this->{$pk} = rad_dbpdo::lastInsertId(); } return $rows; }
function installSQL() { $ver = $this->request('version'); if ($ver and $this->request('hash') == $this->hash()) { $update = rad_update::getInstance(); $update->setUrl($this->_url); $update->setCurrentVersion($ver); if ($update->checkUpdates()) { $response = $update->getUpdatesList(); if (!empty($response->sql)) { $vars = array('RAD' => RAD); foreach ($response->sql as $sql) { $update->execSQL($sql->sql, $vars); if (!empty($sql->inserted_id)) { $vars[$sql->inserted_id] = rad_dbpdo::lastInsertId(); } } } die('Done!'); } else { die('Have no updates!'); } } else { $this->redirect('404'); } }
/** * Gets the last inserted autoincremnement field * @return integer */ public function inserted_id() { return rad_dbpdo::lastInsertId(); }
function save() { $model = rad_instances::get('model_core_lang'); $id = (int) $this->request('lng_id'); if ($id > 0) { $item = $model->getItem($id); $item->lng_id = $id; } else { $item = new struct_core_lang(); } $item->lng_name = $this->request('lng_name'); $item->lng_code = $this->request('lng_code'); $item->lng_position = $this->request('lng_position'); $item->lng_active = (int) $this->request('lng_active'); $item->lng_mainsite = (int) $this->request('lng_mainsite'); $item->lng_mainadmin = (int) $this->request('lng_mainadmin'); $item->lng_maincontent = (int) $this->request('lng_maincontent'); if ($id > 0) { $model->updateItem($item); } else { $model->insertItem($item); $id = rad_dbpdo::lastInsertId(); } echo $this->request('lng_id') > 0 ? 0 : $id; exit; }