<?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);