当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Table::hasColumn方法代码示例

本文整理汇总了PHP中Doctrine_Table::hasColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Table::hasColumn方法的具体用法?PHP Doctrine_Table::hasColumn怎么用?PHP Doctrine_Table::hasColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Table的用法示例。


在下文中一共展示了Doctrine_Table::hasColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildForeignKeys

 /**
  * Generates foreign keys for the plugin table based on the owner table.
  * These columns are automatically added to the generated model so we can
  * create foreign keys back to the table object that owns the plugin.
  *
  * @param Doctrine_Table $table     the table object that owns the plugin
  * @return array                    an array of foreign key definitions
  */
 public function buildForeignKeys(Doctrine_Table $table)
 {
     $fk = array();
     foreach ((array) $table->getIdentifier() as $field) {
         $def = $table->getDefinitionOf($field);
         unset($def['autoincrement']);
         unset($def['sequence']);
         unset($def['primary']);
         $col = $table->hasColumn($field) ? $field : $table->getColumnName($field) . ' as ' . $field;
         $def['primary'] = true;
         $fk[$col] = $def;
     }
     return $fk;
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:22,代码来源:Generator.php

示例2: guessColumns

 /**
  * guessColumns
  *
  * @param array $classes                    an array of class names
  * @param Doctrine_Table $foreignTable      foreign table object
  * @return array                            an array of column names
  */
 public function guessColumns(array $classes, Doctrine_Table $foreignTable)
 {
     $conn = $this->_table->getConnection();
     foreach ($classes as $class) {
         try {
             $table = $conn->getTable($class);
         } catch (Doctrine_Table_Exception $e) {
             continue;
         }
         $columns = $this->getIdentifiers($table);
         $found = true;
         foreach ((array) $columns as $column) {
             if (!$foreignTable->hasColumn($column)) {
                 $found = false;
                 break;
             }
         }
         if ($found) {
             break;
         }
     }
     if (!$found) {
         throw new Doctrine_Relation_Exception("Couldn't find columns.");
     }
     return $columns;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:33,代码来源:Parser.php

示例3: do_validate

 /**
  * Helper function to run doctrine level validation on data.  Returns an
  * array('colname' => 'error message').  Only 1 validation error message
  * will be returned per column.
  *
  * @param Doctrine_Table $table
  * @param array   $data
  * @return array
  */
 protected function do_validate($table, $data)
 {
     $errs = array();
     if ($data) {
         // check for static "remote_validate" function on table
         $cls = $table->getClassnameToReturn();
         if (method_exists($cls, self::$VALIDATE_METHOD_NAME)) {
             $myerrs = call_user_func(array($cls, self::$VALIDATE_METHOD_NAME), $data);
             if (count($myerrs)) {
                 return $myerrs;
                 // return early
             }
         }
         // normal doctrine validation
         foreach ($data as $column => $value) {
             if (!$table->hasColumn($column)) {
                 $errs[$column] = 'Unknown column';
             } else {
                 $col_err = false;
                 $stack = $table->validateField($column, $value);
                 // get the first problem (if any)
                 if (isset($stack[$column]) && count($stack[$column])) {
                     $col_err = $stack[$column][0];
                 }
                 $stack->clear();
                 // check extra unique columns, which aren't unique in the
                 // models, but should be validated as such
                 if (!$col_err && in_array($column, $this->enforce_uniques)) {
                     $found = $table->findOneBy($column, $value);
                     if ($found) {
                         $col_err = 'unique';
                     }
                 }
                 // set error for this column
                 if ($col_err) {
                     $errs[$column] = $col_err;
                 }
             }
         }
     }
     return $errs;
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:51,代码来源:validator_controller.php


注:本文中的Doctrine_Table::hasColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。