コード例 #1
0
ファイル: TableSchema.php プロジェクト: addiks/phpsql
 public function getColumn($index)
 {
     if (!is_numeric($index)) {
         $index = $this->getColumnIndex($index);
     }
     assert(is_numeric($index) && $index >= 0);
     $index = (int) $index;
     if (!isset($this->columnCache[$index])) {
         $file = $this->getColumnFile();
         $position = $index * ColumnSchema::PAGE_SIZE;
         $file->seek($position, SEEK_SET);
         $data = $file->read(ColumnSchema::PAGE_SIZE);
         if (strlen($data) !== ColumnSchema::PAGE_SIZE) {
             return null;
         }
         $column = new ColumnSchema();
         $column->setData($data);
         $column->setId($index);
         $this->columnCache[$index] = $column;
     }
     return $this->columnCache[$index];
 }