function installedStuffLookup($title, $tableName)
{
    ?>
					<section>
						<header class="tableRow gray"><h3><?php 
    echo $title;
    ?>
</h3></header>
<?php 
    global $computer;
    $table = new Table($tableName);
    $result = $table->runQuery();
    $installedItems = explode(" - ", $computer[$table->getName() . "_list"]);
    $i = 0;
    foreach ($result as $row) {
        if ($i == 0) {
            echo "\t\t\t\t<div class=\"tableRow\">";
        }
        $isInstalled = in_array($row[$table->getName() . "_name"], $installedItems);
        echo "\t\t\t\t\t\t\t<div class=\"tableCell quarterWidth" . ($isInstalled ? " gray" : "") . "\">\r\n\t\t\t\t\t\t\t\t<label class=\"configLabel\"><input class=\"configCheckbox\" name=\"{$table->getName()}_list[]\" type=\"checkbox\" value=\"{$row[$table->getName() . "_name"]}\"" . ($isInstalled ? " checked" : "") . "/>\r\n\t\t\t\t\t\t\t\t{$row[$table->getName() . "_name"]}</label>\r\n\t\t\t\t\t\t\t</div>\r\n";
        if ($i++ == 3) {
            echo "\t\t\t\t</div>";
            $i = 0;
        }
    }
    ?>
					</section>
<?php 
}
 public function getDropTableDDL(Table $table)
 {
     $ret = '';
     foreach ($table->getForeignKeys() as $fk) {
         $ret .= "\nIF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='" . $fk->getName() . "')\n    ALTER TABLE " . $this->quoteIdentifier($table->getName()) . " DROP CONSTRAINT " . $this->quoteIdentifier($fk->getName()) . ";\n";
     }
     self::$dropCount++;
     $ret .= "\nIF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = '" . $table->getName() . "')\nBEGIN\n    DECLARE @reftable_" . self::$dropCount . " nvarchar(60), @constraintname_" . self::$dropCount . " nvarchar(60)\n    DECLARE refcursor CURSOR FOR\n    select reftables.name tablename, cons.name constraintname\n        from sysobjects tables,\n            sysobjects reftables,\n            sysobjects cons,\n            sysreferences ref\n        where tables.id = ref.rkeyid\n            and cons.id = ref.constid\n            and reftables.id = ref.fkeyid\n            and tables.name = '" . $table->getName() . "'\n    OPEN refcursor\n    FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . "\n    while @@FETCH_STATUS = 0\n    BEGIN\n        exec ('alter table '+@reftable_" . self::$dropCount . "+' drop constraint '+@constraintname_" . self::$dropCount . ")\n        FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . "\n    END\n    CLOSE refcursor\n    DEALLOCATE refcursor\n    DROP TABLE " . $this->quoteIdentifier($table->getName()) . "\nEND\n";
     return $ret;
 }
Example #3
0
 protected function validateTableColumns(Table $table)
 {
     if (!$table->hasPrimaryKey() && !$table->isSkipSql()) {
         $this->errors[] = sprintf('Table "%s" does not have a primary key defined. Propel requires all tables to have a primary key.', $table->getName());
     }
     $phpNames = array();
     foreach ($table->getColumns() as $column) {
         if (in_array($column->getPhpName(), $phpNames)) {
             $this->errors[] = sprintf('Column "%s" declares a phpName already used in table "%s"', $column->getName(), $table->getName());
         }
         $phpNames[] = $column->getPhpName();
     }
 }
Example #4
0
 protected function buildDescription()
 {
     if ($this->foreignTable === null) {
         throw new \yentu\exceptions\DatabaseManipulatorException("No references defined for foreign key {$this->name}");
     }
     return array('columns' => $this->columns, 'table' => $this->table->getName(), 'schema' => $this->table->getSchema()->getName(), 'foreign_columns' => $this->foreignColumns, 'foreign_table' => $this->foreignTable->getName(), 'foreign_schema' => $this->foreignTable->getSchema()->getName(), 'name' => $this->name, 'on_delete' => $this->onDelete, 'on_update' => $this->onUpdate);
 }
Example #5
0
 public function testGetName()
 {
     $db = $this->getMockBuilder(Db::class)->disableOriginalConstructor()->getMock();
     $tableName = 'language';
     $table = new Table($db, $tableName);
     $this->assertSame($tableName, $table->getName());
 }
    protected function addGetLastVersions(&$script)
    {
        $versionTable = $this->behavior->getVersionTable();
        $versionARClassname = $this->builder->getNewStubObjectBuilder($versionTable)->getClassname();
        $versionForeignColumn = $versionTable->getColumn($this->behavior->getParameter('version_column'));
        $fks = $versionTable->getForeignKeysReferencingTable($this->table->getName());
        $relCol = $this->builder->getRefFKPhpNameAffix($fks[0], $plural = true);
        $versionGetter = 'get' . $relCol;
        $versionPeerBuilder = $this->builder->getNewStubPeerBuilder($versionTable);
        $this->builder->declareClassFromBuilder($versionPeerBuilder);
        $versionPeer = $versionPeerBuilder->getClassname();
        $script .= <<<EOF
/**
 * retrieve the last \$number versions.
 *
 * @param integer \$number the number of record to return.
 * @param {$this->getVersionQueryClassName()}|Criteria \$criteria Additional criteria to filter.
 * @param PropelPDO \$con An optional connection to use.
 *
 * @return PropelCollection|{$versionARClassname}[] List of {$versionARClassname} objects
 */
public function getLastVersions(\$number = 10, \$criteria = null, PropelPDO \$con = null)
{
    \$criteria = {$this->getVersionQueryClassName()}::create(null, \$criteria);
    \$criteria->addDescendingOrderByColumn({$versionPeer}::VERSION);
    \$criteria->limit(\$number);

    return \$this->{$versionGetter}(\$criteria, \$con);
}
EOF;
    }
Example #7
0
 public function testTable()
 {
     $table = new Table($this->connection, 'foo_table', array('bar' => TableInterface::TYPE_INT), array());
     $this->assertEquals('foo_table', $table->getName());
     $this->assertEquals(array('bar' => TableInterface::TYPE_INT), $table->getColumns());
     $this->assertEquals(array(), $table->getConnections());
     $table->addConnection('bar', 'bar_table');
     $this->assertEquals(array('bar' => 'bar_table'), $table->getConnections());
 }
 public function staticAttributes($builder)
 {
     $tableName = $this->table->getName();
     $script = "\n/**\n * rank column\n */\nconst RANK_COL = '" . $tableName . '.' . $this->getColumnConstant('rank_column') . "';\n";
     if ($this->behavior->useScope()) {
         if ($this->behavior->hasMultipleScopes()) {
             foreach ($this->behavior->getScopes() as $scope) {
                 $col[] = "{$tableName}." . strtoupper($scope);
             }
             $col = json_encode($col);
             $col = "'{$col}'";
             $script .= "\n/**\n * If defined, the `SCOPE_COL` contains a json_encoded array with all columns.\n * @var boolean\n */\nconst MULTI_SCOPE_COL = true;\n";
         } else {
             $colNames = $this->getColumnConstant('scope_column');
             $col = "'{$tableName}.{$colNames}'";
         }
         $script .= "\n/**\n * Scope column for the set\n */\nconst SCOPE_COL = {$col};\n";
     }
     return $script;
 }
Example #9
0
 /**
  * Constructs where statement for retrieving row(s).
  *
  * @param bool $useDirty
  * @return array
  */
 protected function _getWhereQuery($useDirty = true)
 {
     $where = array();
     $primaryKey = $this->_getPrimaryKey($useDirty);
     $db = $this->_table->getAdapter();
     $tableName = $db->quoteIdentifier($this->_table->getName(), true);
     // retrieve recently updated row using primary keys
     foreach ($primaryKey as $column => $value) {
         $columnName = $db->quoteIdentifier($column, true);
         $where[] = $db->quoteInto("{$tableName}.{$columnName} = ?", $value);
     }
     return $where;
 }
Example #10
0
 /**
  * @param Driver $driver
  * @param Table $table
  * @param Query $query
  * @param bool $asArray
  */
 public function __construct(Driver $driver, Table $table, Query $query, $asArray = false)
 {
     $this->asArray = $asArray;
     $this->table = $table;
     $params = [];
     $this->tableName = $table->getName();
     if (!$this->asArray) {
         $this->recordClasses = [$this->tableName => $table->getDatabase()->getClassMapper()->getClassForRecord($this->tableName)];
     }
     $sql = $query->getRawSql();
     if ($sql === null) {
         $sql = $driver->buildSQL($table, $query, $params);
         $this->fetchStyle = \PDO::FETCH_NUM;
         foreach ($table->getColumns() as $column) {
             if ($column->isPrimaryKey()) {
                 $this->primaryKeyOrdinals[$this->tableName][$column->getOrdinal()] = true;
             }
             $this->columnOrdinalMap[$this->tableName][$column->getOrdinal()] = $column->getName();
         }
         $offset = count($table->getColumns());
         foreach ($query->getJoins() as $join) {
             if (isset($join['cardinality'])) {
                 $joinedTableName = $join['table'];
                 $joinedTable = $table->getDatabase()->getTable($joinedTableName);
                 $this->joinedTables[$joinedTableName] = $joinedTable;
                 if (!$this->asArray) {
                     $this->recordClasses[$joinedTableName] = $joinedTable->getDatabase()->getClassMapper()->getClassForRecord($joinedTableName);
                 }
                 foreach ($joinedTable->getColumns() as $column) {
                     if ($column->isPrimaryKey()) {
                         $this->primaryKeyOrdinals[$joinedTableName][$offset + $column->getOrdinal()] = true;
                     }
                     $this->columnOrdinalMap[$joinedTableName][$offset + $column->getOrdinal()] = $column->getName();
                 }
                 $this->cardinalities[$joinedTableName] = $join['cardinality'];
                 if ($join['cardinality'] === Query::CARDINALITY_ONE_TO_MANY) {
                     $this->properties[$joinedTableName] = $joinedTableName;
                 } else {
                     $this->properties[$joinedTableName] = array_keys($join['on']);
                 }
                 $offset += count($joinedTable->getColumns());
             }
         }
     } else {
         $this->fetchStyle = \PDO::FETCH_ASSOC;
         $this->rawSql = true;
     }
     $this->result = $driver->query($sql, $params);
     $this->fetchNextRow();
 }
Example #11
0
 /**
  * @param Table $old
  * @param Table $new
  * @return bool|string
  */
 public static function computeAlter(Table $old, Table $new)
 {
     $oldColumnNames = array_keys($old->getColumns());
     $newColumnNames = array_keys($new->getColumns());
     $alterLines = [];
     // Check for changed columns
     $possiblyChangedColumnNames = array_intersect($oldColumnNames, $newColumnNames);
     foreach ($possiblyChangedColumnNames as $possiblyChangedColumnName) {
         $oldColumn = $old->getColumn($possiblyChangedColumnName);
         $newColumn = $new->getColumn($possiblyChangedColumnName);
         if ($oldColumn && $newColumn) {
             $alter = Column::computeAlter($oldColumn, $newColumn);
             if ($alter) {
                 $alterLines[] = $alter;
             }
         }
     }
     // check if columns have been added
     $addedColumnNames = array_diff($newColumnNames, $oldColumnNames);
     foreach ($addedColumnNames as $added) {
         $column = $new->getColumn($added);
         $query = "ADD COLUMN " . $column;
         if ($column->isFirst()) {
             $query .= " FIRST";
         } elseif ($column->getAfter() !== false) {
             $query .= " AFTER `" . $column->getAfter() . "`";
         }
         $alterLines[] = $query;
     }
     // check if columns have been removed
     $removedColumnNames = array_diff($oldColumnNames, $newColumnNames);
     foreach ($removedColumnNames as $removedColumnName) {
         $alterLines[] = "DROP COLUMN `" . $removedColumnName . "`";
     }
     if (!empty($alterLines)) {
         return "ALTER TABLE `" . $new->getName() . "`\n\t" . implode(",\n\t", $alterLines);
     }
     return false;
 }
Example #12
0
 public function getPrimaryKeyName(Table $table)
 {
     $tableName = $table->getName();
     // pk constraint name must be 30 chars at most
     $tableName = substr($tableName, 0, min(27, strlen($tableName)));
     return $tableName . '_PK';
 }
 /**
  * Finds the supplied translation table's culture column.
  *
  * @return Column
  *
  * @throws InvalidArgumentException If there is not a column marked as "isCulture"
  */
 protected function getCultureColumn(Table $table)
 {
     foreach ($table->getColumns() as $column) {
         if ('true' == $column->getAttribute('isCulture')) {
             return $column;
         }
     }
     throw new InvalidArgumentException(sprintf('The table "%s" does not have a column marked with the "isCulture" attribute.', $table->getName()));
 }
 public function getDropTableDDL(Table $table)
 {
     return "\nDROP TABLE IF EXISTS " . $this->quoteIdentifier($table->getName()) . ";\n";
 }
Example #15
0
 /**
  * Get the quoted identifier for the table name
  * @param Table $table
  * @return string
  */
 public function getTableBaseIdentifier(Table $table)
 {
     return $this->quoteObjectIdentifier($table->getDatabase()->getPrefix() . $table->getName());
 }
Example #16
0
 /**
  * Loads the primary key for this table.
  */
 protected function addPrimaryKey(Table $table)
 {
     $stmt = $this->dbh->query("SELECT COLUMN_NAME\n            FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS\n            INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ON\n            INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.constraint_name\n            WHERE     (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'PRIMARY KEY') AND\n            (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '" . $table->getName() . "')");
     // Loop through the returned results, grouping the same key_name together
     // adding each column for that key.
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $name = $row[0];
         $table->getColumn($name)->setPrimaryKey(true);
     }
 }
Example #17
0
 /**
  * Returns the Name of the table the column is in
  */
 public function getTableName()
 {
     return $this->parentTable->getName();
 }
Example #18
0
 /**
  * Returns the difference between the tables $table1 and $table2.
  *
  * If there are no differences this method returns the boolean false.
  *
  * @param Table $table1
  * @param Table $table2
  *
  * @return bool|TableDiff
  */
 public function diffTable(Table $table1, Table $table2)
 {
     $changes = 0;
     $tableDifferences = new TableDiff($table1->getName());
     $table1Columns = $table1->getColumns();
     $table2Columns = $table2->getColumns();
     /* See if all the fields in table 1 exist in table 2 */
     foreach ($table2Columns as $columnName => $column) {
         if (!$table1->hasColumn($columnName)) {
             $tableDifferences->addedColumns[$columnName] = $column;
             $changes++;
         }
     }
     /* See if there are any removed fields in table 2 */
     foreach ($table1Columns as $columnName => $column) {
         if (!$table2->hasColumn($columnName)) {
             $tableDifferences->removedColumns[$columnName] = $column;
             $changes++;
         }
     }
     foreach ($table1Columns as $columnName => $column) {
         if ($table2->hasColumn($columnName)) {
             $changedProperties = $this->diffColumn($column, $table2->getColumn($columnName));
             if (count($changedProperties)) {
                 $columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties);
                 $tableDifferences->changedColumns[$column->getName()] = $columnDiff;
                 $changes++;
             }
         }
     }
     $this->detectColumnRenamings($tableDifferences);
     $table1Indexes = $table1->getIndexes();
     $table2Indexes = $table2->getIndexes();
     foreach ($table2Indexes as $index2Name => $index2Definition) {
         foreach ($table1Indexes as $index1Name => $index1Definition) {
             if ($this->diffIndex($index1Definition, $index2Definition) === false) {
                 unset($table1Indexes[$index1Name]);
                 unset($table2Indexes[$index2Name]);
             } else {
                 if ($index1Name == $index2Name) {
                     $tableDifferences->changedIndexes[$index2Name] = $table2Indexes[$index2Name];
                     unset($table1Indexes[$index1Name]);
                     unset($table2Indexes[$index2Name]);
                     $changes++;
                 }
             }
         }
     }
     foreach ($table1Indexes as $index1Name => $index1Definition) {
         $tableDifferences->removedIndexes[$index1Name] = $index1Definition;
         $changes++;
     }
     foreach ($table2Indexes as $index2Name => $index2Definition) {
         $tableDifferences->addedIndexes[$index2Name] = $index2Definition;
         $changes++;
     }
     $fromFkeys = $table1->getForeignKeys();
     $toFkeys = $table2->getForeignKeys();
     foreach ($fromFkeys as $key1 => $constraint1) {
         foreach ($toFkeys as $key2 => $constraint2) {
             if ($this->diffForeignKey($constraint1, $constraint2) === false) {
                 unset($fromFkeys[$key1]);
                 unset($toFkeys[$key2]);
             } else {
                 if (strtolower($constraint1->getName()) == strtolower($constraint2->getName())) {
                     $tableDifferences->changedForeignKeys[] = $constraint2;
                     $changes++;
                     unset($fromFkeys[$key1]);
                     unset($toFkeys[$key2]);
                 }
             }
         }
     }
     foreach ($fromFkeys as $key1 => $constraint1) {
         $tableDifferences->removedForeignKeys[] = $constraint1;
         $changes++;
     }
     foreach ($toFkeys as $key2 => $constraint2) {
         $tableDifferences->addedForeignKeys[] = $constraint2;
         $changes++;
     }
     return $changes ? $tableDifferences : false;
 }
Example #19
0
 /**
  * Adds vendor-specific info for table.
  *
  * @param      Table $table
  */
 protected function addTableVendorInfo(Table $table)
 {
     $stmt = $this->dbh->query("SHOW TABLE STATUS LIKE '" . $table->getName() . "'");
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $vi = $this->getNewVendorInfoObject($row);
     $table->addVendorInfo($vi);
 }
 /**
  * Loads the primary key for this table.
  *
  * @param Table $table The Table model class to add PK to.
  */
 protected function addPrimaryKey(Table $table)
 {
     $stmt = $this->dbh->query("SELECT COLS.COLUMN_NAME FROM USER_CONSTRAINTS CONS, USER_CONS_COLUMNS COLS WHERE CONS.CONSTRAINT_NAME = COLS.CONSTRAINT_NAME AND CONS.TABLE_NAME = '" . $table->getName() . "' AND CONS.CONSTRAINT_TYPE = 'P'");
     /* @var stmt PDOStatement */
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         // This fixes a strange behavior by PDO. Sometimes the
         // row values are inside an index 0 of an array
         if (array_key_exists(0, $row)) {
             $row = $row[0];
         }
         $table->getColumn($row['COLUMN_NAME'])->setPrimaryKey(true);
     }
 }
Example #21
0
 /**
  * @param \Doctrine\DBAL\Schema\Table                $localTable
  * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey
  *
  * @return \Doctrine\DBAL\Schema\SchemaException
  */
 public static function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey)
 {
     return new self("The performed schema operation on " . $localTable->getName() . " requires a named foreign key, " . "but the given foreign key from (" . implode(", ", $foreignKey->getColumns()) . ") onto foreign table " . "'" . $foreignKey->getForeignTableName() . "' (" . implode(", ", $foreignKey->getForeignColumns()) . ") is currently " . "unnamed.");
 }
 /**
  * Load indexes for this table
  */
 protected function addIndexes(Table $table)
 {
     $stmt = $this->dbh->query("PRAGMA index_list('" . $table->getName() . "')");
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $name = $row['name'];
         $index = new Index($name);
         $stmt2 = $this->dbh->query("PRAGMA index_info('" . $name . "')");
         while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
             $colname = $row2['name'];
             $index->addColumn($table->getColumn($colname));
         }
         $table->addIndex($index);
     }
 }
Example #23
0
 public function getName()
 {
     return str_replace(' KEY', '', $this->type) . '__' . $this->table->getName() . '__' . implode('_', $this->fields);
 }
Example #24
0
 /**
  * @param Table $table
  * @return $this
  */
 public function removeDependantTable(Table $table)
 {
     if (isset($this->dependantTables[$table->getName()])) {
         unset($this->dependantTables[$table->getName()]);
         $table->removeGuardianTable($this);
     }
     return $this;
 }
 /**
  * Builds the DDL SQL to drop the primary key of a table.
  *
  * @param      Table $table
  * @return     string
  */
 public function getDropPrimaryKeyDDL(Table $table)
 {
     $pattern = "\nALTER TABLE %s DROP PRIMARY KEY;\n";
     return sprintf($pattern, $this->quoteIdentifier($table->getName()));
 }
Example #26
0
 public function testQualifiedName()
 {
     $table = new Table();
     $table->setSchema("foo");
     $table->setCommonName("bar");
     $this->assertEquals($table->getName(), "bar");
     $this->assertEquals($table->getCommonName(), "bar");
     $database = new Database();
     $database->addTable($table);
     $database->setPlatform(new NoSchemaPlatform());
     $this->assertEquals($table->getName(), "bar");
     $database->setPlatform(new SchemaPlatform());
     $this->assertEquals($table->getName(), "foo.bar");
 }
Example #27
0
 public function testGetName()
 {
     $this->assertSame("test", $this->table->getName());
 }
Example #28
0
 /**
  * Adds vendor-specific info for table.
  *
  * @param Table $table
  */
 protected function addTableVendorInfo(Table $table)
 {
     $stmt = $this->dbh->query("SHOW TABLE STATUS LIKE '" . $table->getName() . "'");
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     if (!$this->addVendorInfo) {
         //since we depend on `Engine` in the MysqlPlatform, we have always extract this vendor information
         $row = array('Engine' => $row['Engine']);
     }
     $vi = $this->getNewVendorInfoObject($row);
     $table->addVendorInfo($vi);
 }
 /**
  * Adds Columns to the specified table.
  *
  * @param      Table $table The Table model class to add columns to.
  * @param      int $oid The table OID
  * @param      string $version The database version.
  */
 protected function addColumns(Table $table, $oid, $version)
 {
     // Get the columns, types, etc.
     // Based on code from pgAdmin3 (http://www.pgadmin.org/)
     $stmt = $this->dbh->prepare("SELECT\n\t\t\t\t\t\t\t\t        att.attname,\n\t\t\t\t\t\t\t\t        att.atttypmod,\n\t\t\t\t\t\t\t\t        att.atthasdef,\n\t\t\t\t\t\t\t\t        att.attnotnull,\n\t\t\t\t\t\t\t\t        def.adsrc,\n\t\t\t\t\t\t\t\t        CASE WHEN att.attndims > 0 THEN 1 ELSE 0 END AS isarray,\n\t\t\t\t\t\t\t\t        CASE\n\t\t\t\t\t\t\t\t            WHEN ty.typname = 'bpchar'\n\t\t\t\t\t\t\t\t                THEN 'char'\n\t\t\t\t\t\t\t\t            WHEN ty.typname = '_bpchar'\n\t\t\t\t\t\t\t\t                THEN '_char'\n\t\t\t\t\t\t\t\t            ELSE\n\t\t\t\t\t\t\t\t                ty.typname\n\t\t\t\t\t\t\t\t        END AS typname,\n\t\t\t\t\t\t\t\t        ty.typtype\n\t\t\t\t\t\t\t\t    FROM pg_attribute att\n\t\t\t\t\t\t\t\t        JOIN pg_type ty ON ty.oid=att.atttypid\n\t\t\t\t\t\t\t\t        LEFT OUTER JOIN pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum\n\t\t\t\t\t\t\t\t    WHERE att.attrelid = ? AND att.attnum > 0\n\t\t\t\t\t\t\t\t        AND att.attisdropped IS FALSE\n\t\t\t\t\t\t\t\t    ORDER BY att.attnum");
     $stmt->bindValue(1, $oid, PDO::PARAM_INT);
     $stmt->execute();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $size = null;
         $precision = null;
         $scale = null;
         // Check to ensure that this column isn't an array data type
         if ((int) $row['isarray'] === 1) {
             throw new EngineException(sprintf("Array datatypes are not currently supported [%s.%s]", $this->name, $row['attname']));
         }
         // if (((int) $row['isarray']) === 1)
         $name = $row['attname'];
         // If they type is a domain, Process it
         if (strtolower($row['typtype']) == 'd') {
             $arrDomain = $this->processDomain($row['typname']);
             $type = $arrDomain['type'];
             $size = $arrDomain['length'];
             $precision = $size;
             $scale = $arrDomain['scale'];
             $boolHasDefault = strlen(trim($row['atthasdef'])) > 0 ? $row['atthasdef'] : $arrDomain['hasdefault'];
             $default = strlen(trim($row['adsrc'])) > 0 ? $row['adsrc'] : $arrDomain['default'];
             $is_nullable = strlen(trim($row['attnotnull'])) > 0 ? $row['attnotnull'] : $arrDomain['notnull'];
             $is_nullable = $is_nullable == 't' ? false : true;
         } else {
             $type = $row['typname'];
             $arrLengthPrecision = $this->processLengthScale($row['atttypmod'], $type);
             $size = $arrLengthPrecision['length'];
             $precision = $size;
             $scale = $arrLengthPrecision['scale'];
             $boolHasDefault = $row['atthasdef'];
             $default = $row['adsrc'];
             $is_nullable = $row['attnotnull'] == 't' ? false : true;
         }
         // else (strtolower ($row['typtype']) == 'd')
         $autoincrement = null;
         // if column has a default
         if ($boolHasDefault == 't' && strlen(trim($default)) > 0) {
             if (!preg_match('/^nextval\\(/', $default)) {
                 $strDefault = preg_replace('/::[\\W\\D]*/', '', $default);
                 $default = str_replace("'", '', $strDefault);
             } else {
                 $autoincrement = true;
                 $default = null;
             }
         } else {
             $default = null;
         }
         $propelType = $this->getMappedPropelType($type);
         if (!$propelType) {
             $propelType = Column::DEFAULT_TYPE;
             $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support.");
         }
         $column = new Column($name);
         $column->setTable($table);
         $column->setDomainForType($propelType);
         // We may want to provide an option to include this:
         // $column->getDomain()->replaceSqlType($type);
         $column->getDomain()->replaceSize($size);
         $column->getDomain()->replaceScale($scale);
         if ($default !== null) {
             if (in_array($default, array('now()'))) {
                 $type = ColumnDefaultValue::TYPE_EXPR;
             } else {
                 $type = ColumnDefaultValue::TYPE_VALUE;
             }
             $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, $type));
         }
         $column->setAutoIncrement($autoincrement);
         $column->setNotNull(!$is_nullable);
         $table->addColumn($column);
     }
 }
 public function getPrimaryKeyName(Table $table)
 {
     $tableName = $table->getName();
     return $tableName . '_pkey';
 }