fetchTableCols() public method

Returns an array describing table columns from the cache; if the cache entry is not available, queries the database for the column descriptions.
public fetchTableCols ( string $spec ) : array
$spec string The table or schema.table to fetch columns for.
return array An array of table columns.
コード例 #1
0
 /**
  * 
  * Fixes table column definitions in $_table_cols.
  * 
  * @return void
  * 
  */
 protected function _fixTableCols()
 {
     // should we scan the table cols at the database?
     if (!$this->_config['table_scan']) {
         // table scans turned off. assume that $_table_cols is mostly
         // correct and force population of the minimum key set.
         $cols = $this->_fixCols($this->_table_cols);
     } else {
         // scan the database table for column descriptions
         try {
             // get the column descriptions from the database
             $cols = $this->_sql->fetchTableCols($this->_table_name);
         } catch (Solar_Sql_Adapter_Exception_QueryFailed $e) {
             // does the table exist in the database?
             $list = $this->_sql->fetchTableList();
             if (!in_array($this->_table_name, $list)) {
                 // no, try to create it ...
                 $this->_createTableAndIndexes();
                 // ... and get the column descriptions
                 $cols = $this->_sql->fetchTableCols($this->_table_name);
             } else {
                 // found the table, must have been something else wrong
                 throw $e;
             }
         }
         // @todo add a "sync" check to see if column data in the class
         // matches column data in the database, and throw an exception
         // if they don't match pretty closely.
     }
     // reset to the fixed columns
     $this->_table_cols = $cols;
 }