Source for file pgsql.daobuilder.php

Documentation is available at pgsql.daobuilder.php

  1. <?php
  2. /**
  3. @package    jelix
  4. @subpackage db_driver
  5. @author     Laurent Jouanneau
  6. @copyright  2007-2010 Laurent Jouanneau
  7. @link      http://www.jelix.org
  8. @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
  9. */
  10.  
  11. /**
  12.  * driver for jDaoCompiler
  13.  * @package    jelix
  14.  * @subpackage db_driver
  15.  */
  16. class pgsqlDaoBuilder extends jDaoGenerator {
  17.  
  18.     protected $propertiesListForInsert = 'PrimaryFieldsExcludeAutoIncrement';
  19.  
  20.     protected function buildUpdateAutoIncrementPK($pkai{
  21.         return '          $record->'.$pkai->name.'= $this->_conn->lastInsertId(\''.$pkai->sequenceName.'\');';
  22.     }
  23.  
  24.     protected function getAutoIncrementPKField ($using null){
  25.         if ($using === null){
  26.             $using $this->_dataParser->getProperties ();
  27.         }
  28.  
  29.         $tb $this->_dataParser->getTables();
  30.         $tb $tb[$this->_dataParser->getPrimaryTable()]['realname'];
  31.  
  32.         foreach ($using as $id=>$field{
  33.             if(!$field->isPK)
  34.                 continue;
  35.             if ($field->autoIncrement{
  36.                if(!strlen($field->sequenceName)){
  37.                   $field->sequenceName $tb.'_'.$field->name.'_seq';
  38.                }
  39.                return $field;
  40.             }
  41.         }
  42.         return null;
  43.     }
  44.  
  45.     protected function buildEndOfClass({
  46.         $fields $this->_getPropertiesBy('BinaryField');
  47.         if (count($fields)) {
  48.  
  49.             $src '    protected function finishInitResultSet($rs) {
  50.         $rs->setFetchMode(8,$this->_DaoRecordClassName);
  51.         $rs->addModifier(array($this, \'unescapeRecord\'));
  52.     }'."\n";
  53.  
  54.             // we build the callback function for the resultset, to unescape
  55.             // binary fields.
  56.             $src .= 'public function unescapeRecord($record, $resultSet) {'."\n";
  57.             foreach ($fields as $f{
  58.                 $src .= '$record->'.$f->name.' = $resultSet->unescapeBin($record->'.$f->name.");\n";
  59.             }
  60.             $src .= '}';
  61.             return $src;
  62.         }
  63.         return '';
  64.     }
  65. }

Documentation generated on Mon, 19 Sep 2011 14:14:07 +0200 by phpDocumentor 1.4.3