コード例 #1
0
ファイル: Table.php プロジェクト: michaelnavarro/zc
 /**
  * Get a column instance
  * 
  * @param  string $columnName
  * @return Column
  */
 public function getColumn($columnName)
 {
     $columnName = strtolower($columnName);
     if (!$this->hasColumn($columnName)) {
         throw SchemaException::columnDoesNotExist($columnName, $this->_name);
     }
     return $this->_columns[$columnName];
 }
コード例 #2
0
 /**
  * Returns the Column with the given name.
  *
  * @param string $columnName The column name.
  *
  * @return Column
  *
  * @throws SchemaException If the column does not exist.
  */
 public function getColumn($columnName)
 {
     $columnName = $this->normalizeIdentifier($columnName);
     if (!$this->hasColumn($columnName)) {
         throw SchemaException::columnDoesNotExist($columnName, $this->_name);
     }
     return $this->_columns[$columnName];
 }
コード例 #3
0
ファイル: Table.php プロジェクト: BozzaCoon/SPHERE-Framework
 /**
  * Adds a foreign key constraint with a given name.
  *
  * @deprecated Use {@link addForeignKeyConstraint}
  *
  * @param string       $name
  * @param Table|string $foreignTable Table schema instance or table name
  * @param array        $localColumnNames
  * @param array        $foreignColumnNames
  * @param array        $options
  *
  * @return self
  *
  * @throws SchemaException
  */
 public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = array())
 {
     if ($foreignTable instanceof Table) {
         foreach ($foreignColumnNames as $columnName) {
             if (!$foreignTable->hasColumn($columnName)) {
                 throw SchemaException::columnDoesNotExist($columnName, $foreignTable->getName());
             }
         }
     }
     foreach ($localColumnNames as $columnName) {
         if (!$this->hasColumn($columnName)) {
             throw SchemaException::columnDoesNotExist($columnName, $this->_name);
         }
     }
     $constraint = new ForeignKeyConstraint($localColumnNames, $foreignTable, $foreignColumnNames, $name, $options);
     $this->_addForeignKeyConstraint($constraint);
     return $this;
 }
コード例 #4
0
 /**
  * Builds the ORDER BY part
  * @param QueryBuilder $qb
  * @param array $order_by
  * @return self
  */
 protected function buildOrderBy(QueryBuilder $qb, array $order_by = [])
 {
     foreach ($order_by as $order) {
         $column = null;
         $direction = 'ASC';
         if (is_string($order)) {
             $column = $order;
         } elseif (is_array($order) && count($order) === 2) {
             list($column, $direction) = $order;
         }
         if ($column === null || $this->getColumn($column) === null) {
             throw Schema\SchemaException::columnDoesNotExist($column, $this->table_name);
         }
         if (!in_array($direction, ['ASC', 'DESC'])) {
             throw QueryBuilderException::orderByDirectionDoesNotExist($direction);
         }
         $qb->addOrderBy($this->conn->quoteIdentifier($column), $direction);
     }
     return $this;
 }