Пример #1
0
<?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 == 'loadPostingtype') {
    header('Content-Type: application/json');
    $db = ConnectionFactory::getConnection();
    $postingtypeDAO = new PostingtypeDAO($db);
    $id = isset($params['id']) ? (int) trim($params['id']) : 0;
    if ($id <= 0) {
        $rows = array(Postingtype::createDefault());
    } else {
        $sql = <<<EOF
select * from postingtype pri where pri.id = ?
EOF;
        $ps = new PreparedStatement($sql, 0, 1);
        $ps->setInt($id);
        $rows = $postingtypeDAO->findWithPreparedStatement($ps);
    }
    echo json_encode($rows);
    $db->close();
    exit;
}
                     $db->commitTransaction();
                     $committed = true;
                     $result->successMsg .= sprintf(_t('crud.idUpdated'), _t('crud.postingtype.tableDescription', 'Postingtype'), $row->id) . "\n";
                 }
             }
             if (!$success) {
                 if ($result->errorMsg == '' && empty($result->fieldErrors)) {
                     $result->errorMsg .= sprintf(_t('crud.rowCouldNotBeUpdated'), _t('crud.postingtype.tableDescription', 'Postingtype')) . "\n";
                 }
             }
         }
     }
 } else {
     // if ($row->id > 0)
     // Convert the value object into the actual entity.
     $newRow = new Postingtype();
     $newRow->loadFromArray((array) $row);
     if (function_exists('preInsertHook')) {
         preInsertHook();
     }
     try {
         $success = $postingtypeDAO->insert($newRow);
     } catch (Exception $ex) {
         $success = false;
     }
     if ($success) {
         $row->id = $newRow->id;
         $justInsertedRowId = $newRow->id;
         if (function_exists('postInsertHook')) {
             postInsertHook();
         }
 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 Postingtype();
         $row->loadFromArray($arr);
         $rows[] = $row;
     }
     $this->connection->freeResult($rs);
     if ($this->cache !== null) {
         $this->cache->set($cacheKey, $rows);
     }
     return $rows;
 }