$db->commitTransaction(); $committed = true; $result->successMsg .= sprintf(_t('crud.idUpdated'), _t('crud.approle.tableDescription', 'Role'), $row->id) . "\n"; } } if (!$success) { if ($result->errorMsg == '' && empty($result->fieldErrors)) { $result->errorMsg .= sprintf(_t('crud.rowCouldNotBeUpdated'), _t('crud.approle.tableDescription', 'Role')) . "\n"; } } } } } else { // if ($row->id > 0) // Convert the value object into the actual entity. $newRow = new Approle(); $newRow->loadFromArray((array) $row); if (function_exists('preInsertHook')) { preInsertHook(); } try { $success = $approleDAO->insert($newRow); } catch (Exception $ex) { $success = false; } if ($success) { $row->id = $newRow->id; $justInsertedRowId = $newRow->id; if (function_exists('postInsertHook')) { postInsertHook(); }
<?php // DO NOT EDIT THIS FILE. // This file was generated by searchgen. // If you need to customize this file, please edit the corresponding // yaml file in the gencfg directory, and then re-generate this file // by running searchgen, passing in the table name. if (isset($command) && $command == 'loadApprole') { header('Content-Type: application/json'); $db = ConnectionFactory::getConnection(); $approleDAO = new ApproleDAO($db); $apppermDAO = new ApppermDAO($db); $id = isset($params['id']) ? (int) trim($params['id']) : 0; if ($id <= 0) { $rows = array(Approle::createDefault()); } else { $sql = <<<EOF select * from approle pri where pri.id = ? EOF; $ps = new PreparedStatement($sql, 0, 1); $ps->setInt($id); $rows = $approleDAO->findWithPreparedStatement($ps); } $ps1 = new PreparedStatement(<<<EOF select distinct p.* from approleperm r_p inner join appperm p on p.perm_name = r_p.perm_name where r_p.role_name = ? order by p.perm_name EOF , 0, 0); foreach ($rows as &$row) { $ps1->clearParams(); $ps1->setString($row->role_name); $row->perms = $id <= 0 ? array() : $apppermDAO->findWithPreparedStatement($ps1);
public static function createDefault() { $v = new Approle(); $v->defaultAllFields(); return $v; }
public function findWithPreparedStatement($ps) { $cacheKey = null; if ($this->cache !== null) { $cacheKey = serialize($ps); if (($rows = $this->cache->get($cacheKey)) !== false) { return $rows; } } $rows = array(); $rs = $this->connection->executeQuery($ps); while ($arr = $this->connection->fetchArray($rs)) { $row = new Approle(); $row->loadFromArray($arr); $rows[] = $row; } $this->connection->freeResult($rs); if ($this->cache !== null) { $this->cache->set($cacheKey, $rows); } return $rows; }