Ejemplo n.º 1
0
 /**
  * Return all columns
  * @return array
  */
 protected function _getColumns()
 {
     $columns = array();
     foreach ($this->_table->getColumns() as $name => $definition) {
         if (isset($definition['primary']) && $definition['primary'] || !isset($this->_columnTypes[$definition['type']]) || in_array($name, $this->_ignoreColumns)) {
             continue;
         }
         $definition['fieldName'] = $this->_table->getFieldName($name);
         $columns[$name] = $definition;
     }
     return $columns;
 }
Ejemplo n.º 2
0
 /**
  * Return all columns as an array
  *
  * Array must contain 'type' for column type, 'notnull' true/false
  * for the column's nullability, and 'values' for enum values, 'primary'
  * true/false for primary key. Key = column's name
  *
  * @return array
  */
 public function getColumns()
 {
     $foreignKeyColumns = array();
     foreach ($this->_table->getRelations() as $alias => $relation) {
         $localColumn = strtolower($relation['local']);
         $foreignKeyColumns[$localColumn] = $relation['class'];
     }
     $data = $this->_table->getColumns();
     $cols = array();
     foreach ($data as $name => $def) {
         $isPrimary = isset($def['primary']) ? $def['primary'] : false;
         $isForeignKey = isset($foreignKeyColumns[strtolower($name)]);
         $columnName = $this->_table->getColumnName($name);
         $fieldName = $this->_table->getFieldName($columnName);
         $cols[$fieldName] = array('type' => $def['type'], 'notnull' => isset($def['notnull']) ? $def['notnull'] : false, 'values' => isset($def['values']) ? $def['values'] : array(), 'primary' => $isPrimary, 'foreignKey' => $isForeignKey, 'class' => $isForeignKey ? $foreignKeyColumns[strtolower($name)] : null);
     }
     return $cols;
 }
Ejemplo n.º 3
0
 /**
  * Get the alias/field name
  *
  * @return string $fieldName
  */
 public function getFieldName()
 {
     return $this->table->getFieldName($this->getName());
 }