public function indexAction()
 {
     $db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => 'alphahyd'));
     $aTables = $db->listTables();
     $this->view->tables = $aTables;
     $sql = 'SHOW COLUMNS FROM alphahyd.tmp';
     $aRowTables = $db->describeTable('categories');
     $this->view->rowTable = $aRowTables;
     //var_dump($aRowTables);
 }
Exemplo n.º 2
0
 /**
  * Returns the column descriptions for a table.
  *
  * The return value is an associative array keyed by the column name,
  * as returned by the RDBMS.
  *
  * The value of each array element is an associative array
  * with the following keys:
  *
  * SCHEMA_NAME      => string; name of database or schema
  * TABLE_NAME       => string;
  * COLUMN_NAME      => string; column name
  * COLUMN_POSITION  => number; ordinal position of column in table
  * DATA_TYPE        => string; SQL datatype name of column
  * DEFAULT          => string; default expression of column, null if none
  * NULLABLE         => boolean; true if column can have nulls
  * LENGTH           => number; length of CHAR/VARCHAR
  * SCALE            => number; scale of NUMERIC/DECIMAL
  * PRECISION        => number; precision of NUMERIC/DECIMAL
  * UNSIGNED         => boolean; unsigned property of an integer type
  * PRIMARY          => boolean; true if column is part of the primary key
  * PRIMARY_POSITION => integer; position of column in primary key
  * IDENTITY         => integer; true if column is auto-generated with unique values
  *
  * @param string $tableName
  * @param string $schemaName OPTIONAL
  * @return array
  */
 public function describeTable($tableName, $schemaName = null)
 {
     $cacheKey = $this->_getTableName($tableName, $schemaName);
     $ddl = $this->loadDdlCache($cacheKey, self::DDL_DESCRIBE);
     if ($ddl === false) {
         $ddl = parent::describeTable($tableName, $schemaName);
         /**
          * Remove bug in some MySQL versions, when int-column without default value is described as:
          * having default empty string value
          */
         $affected = array('tinyint', 'smallint', 'mediumint', 'int', 'bigint');
         foreach ($ddl as $key => $columnData) {
             if ($columnData['DEFAULT'] === '' && array_search($columnData['DATA_TYPE'], $affected) !== FALSE) {
                 $ddl[$key]['DEFAULT'] = null;
             }
         }
         $this->saveDdlCache($cacheKey, self::DDL_DESCRIBE, $ddl);
     }
     return $ddl;
 }
Exemplo n.º 3
0
 /**
  * Returns the column descriptions for a table.
  *
  * The return value is an associative array keyed by the column name,
  * as returned by the RDBMS.
  *
  * The value of each array element is an associative array
  * with the following keys:
  *
  * SCHEMA_NAME      => string; name of database or schema
  * TABLE_NAME       => string;
  * COLUMN_NAME      => string; column name
  * COLUMN_POSITION  => number; ordinal position of column in table
  * DATA_TYPE        => string; SQL datatype name of column
  * DEFAULT          => string; default expression of column, null if none
  * NULLABLE         => boolean; true if column can have nulls
  * LENGTH           => number; length of CHAR/VARCHAR
  * SCALE            => number; scale of NUMERIC/DECIMAL
  * PRECISION        => number; precision of NUMERIC/DECIMAL
  * UNSIGNED         => boolean; unsigned property of an integer type
  * PRIMARY          => boolean; true if column is part of the primary key
  * PRIMARY_POSITION => integer; position of column in primary key
  * IDENTITY         => integer; true if column is auto-generated with unique values
  *
  * @param string $tableName
  * @param string $schemaName OPTIONAL
  * @return array
  */
 public function describeTable($tableName, $schemaName = null)
 {
     $cacheKey = $this->_getTableName($tableName, $schemaName);
     $ddl = $this->loadDdlCache($cacheKey, self::DDL_DESCRIBE);
     if ($ddl === false) {
         $ddl = parent::describeTable($tableName, $schemaName);
         $this->saveDdlCache($cacheKey, self::DDL_DESCRIBE, $ddl);
     }
     return $ddl;
 }
Exemplo n.º 4
0
 /**
  * Returns the column descriptions for a table.
  *
  * The return value is an associative array keyed by the column name,
  * as returned by the RDBMS.
  *
  * The value of each array element is an associative array
  * with the following keys:
  *
  * SCHEMA_NAME      => string; name of database or schema
  * TABLE_NAME       => string;
  * COLUMN_NAME      => string; column name
  * COLUMN_POSITION  => number; ordinal position of column in table
  * DATA_TYPE        => string; SQL datatype name of column
  * DEFAULT          => string; default expression of column, null if none
  * NULLABLE         => boolean; true if column can have nulls
  * LENGTH           => number; length of CHAR/VARCHAR
  * SCALE            => number; scale of NUMERIC/DECIMAL
  * PRECISION        => number; precision of NUMERIC/DECIMAL
  * UNSIGNED         => boolean; unsigned property of an integer type
  * PRIMARY          => boolean; true if column is part of the primary key
  * PRIMARY_POSITION => integer; position of column in primary key
  * IDENTITY         => integer; true if column is auto-generated with unique values
  *
  * @param string $tableName
  * @param string $schemaName OPTIONAL
  * @return array
  */
 public function describeTable($tableName, $schemaName = null)
 {
     $cacheKey = $this->_getTableName($tableName, $schemaName);
     if (!isset($this->_ddlCache[self::DDL_DESCRIBE][$cacheKey])) {
         $this->_ddlCache[self::DDL_DESCRIBE][$cacheKey] = parent::describeTable($tableName, $schemaName);
     }
     return $this->_ddlCache[self::DDL_DESCRIBE][$cacheKey];
 }
Exemplo n.º 5
0
 /**
  * Returns the column descriptions for a table.
  *
  * The return value is an associative array keyed by the column name,
  * as returned by the RDBMS.
  *
  * The value of each array element is an associative array
  * with the following keys:
  *
  * SCHEMA_NAME      => string; name of database or schema
  * TABLE_NAME       => string;
  * COLUMN_NAME      => string; column name
  * COLUMN_POSITION  => number; ordinal position of column in table
  * DATA_TYPE        => string; SQL datatype name of column
  * DEFAULT          => string; default expression of column, null if none
  * NULLABLE         => boolean; true if column can have nulls
  * LENGTH           => number; length of CHAR/VARCHAR
  * SCALE            => number; scale of NUMERIC/DECIMAL
  * PRECISION        => number; precision of NUMERIC/DECIMAL
  * UNSIGNED         => boolean; unsigned property of an integer type
  * PRIMARY          => boolean; true if column is part of the primary key
  * PRIMARY_POSITION => integer; position of column in primary key
  * IDENTITY         => integer; true if column is auto-generated with unique values
  *
  * @param string $tableName
  * @param string $schemaName OPTIONAL
  * @return array
  */
 public function describeTable($tableName, $schemaName = null)
 {
     $key = $tableName;
     if ($schemaName) {
         $key = $schemaName . '.' . $key;
     }
     if (!isset($this->_describesCache[$key])) {
         $this->_describesCache[$key] = parent::describeTable($tableName, $schemaName);
     }
     return $this->_describesCache[$key];
 }