예제 #1
0
파일: Table.php 프로젝트: wells5609/wp-app
 /**
  * Fetches column metadata from the database.
  * 
  * @return array
  */
 protected function fetchColumns()
 {
     $cache_key = 'wpapp_db_col_' . get_current_blog_id() . $this->tableName;
     $cached = wp_cache_get($cache_key, 'dbmeta', false, $found);
     if ($found && $cached) {
         return $cached;
     }
     $results = (array) $this->connection->wpdb()->get_results("select C.COLUMN_NAME, C.COLUMN_DEFAULT, C.DATA_TYPE, C.CHARACTER_MAXIMUM_LENGTH, " . "C.NUMERIC_PRECISION, C.IS_NULLABLE, C.COLUMN_KEY, C.EXTRA, C.COLLATION_NAME " . "from INFORMATION_SCHEMA.COLUMNS as C where C.TABLE_NAME = '{$this->tableName}'");
     $columns = array();
     foreach ($results as $data) {
         $column = new Table\Column($data);
         $columns[$column->name] = $column;
     }
     wp_cache_set($cache_key, $columns, 'dbmeta', 600);
     return $columns;
 }