public function getColumns() { $this->columnsLockFile->acquireRead(); if ($this->columnsLockFile->wasModified()) { $this->columnsLockFile->accept(); $this->columnsFile->acquireRead(); $columnsHandle = $this->columnsFile->getHandle(); $line = fgets($columnsHandle); if (!preg_match("/^(\\d+)/", $line, $matches)) { $this->columnsFile->releaseRead(); $this->columnsLockFile->releaseRead(); return false; } $num_columns = $matches[1]; for ($i = 0; $i < $num_columns; ++$i) { $line = fgets($columnsHandle, 4096); if (preg_match("/(\\S+): (dt|d|i|f|s|t|e);(.*);(0|1);(-?\\d+(?:\\.\\d+)?|'.*'|NULL);(p|u|k|n);(0|1);/", $line, $matches)) { $name = $matches[1]; $type = $matches[2]; $restraintString = $matches[3]; $auto = (int) $matches[4]; $default = $matches[5]; $null = (int) $matches[7]; if ($type === Types::INTEGER) { $default = (int) $default; } elseif ($type === Types::FLOAT) { $default = (double) $default; } elseif ($default[0] == "'" && substr($default, -1) == "'") { $default = substr($default, 1, -1); } elseif ($default === 'NULL') { $default = null; } if ($auto === 1 && !empty($restraintString)) { list($current, $always, $start, $increment, $min, $max, $cycle) = explode(',', $restraintString); $restraint = array((int) $current, (int) $always, (int) $start, (int) $increment, (int) $min, (int) $max, (int) $cycle); } elseif ($type === Types::ENUM && preg_match_all("/'(.*?(?<!\\\\))'/", $restraintString, $enumMatches) !== false) { $restraint = $enumMatches[1]; } else { $restraint = array(); } $this->columns[$name] = array('type' => $type, 'auto' => $auto, 'default' => $default, 'key' => $matches[6], 'null' => $null, 'restraint' => $restraint); } else { $this->columnsFile->releaseRead(); $this->columnsLockFile->releaseRead(); return false; } } $this->columnsFile->releaseRead(); } $this->columnsLockFile->releaseRead(); return parent::getColumns(); }