public function __construct($tableName, NConnection $connection, IReflection $reflection) { $this->tableName = $tableName; $this->databaseReflection = $reflection; $this->driver = $connection->getSupplementalDriver(); $this->driverName = $connection->getAttribute(PDO::ATTR_DRIVER_NAME); $this->delimitedTable = $this->tryDelimite($tableName); }
protected function tryDelimite($s) { $driver = $this->connection->getSupplementalDriver(); return preg_replace_callback('#(?<=[\s,<>=]|^)[a-z_][a-z0-9_.]*(?=[\s,<>=]|$)#i', create_function('$m', 'extract(NCFix::$vars['.NCFix::uses(array('driver'=>$driver)).'], EXTR_REFS); return strtoupper($m[0]) === $m[0] ? $m[0] : implode(\'.\', array_map(array($driver, \'delimite\'), explode(\'.\', $m[0]))); '), $s); }
protected function reloadForeignKeys($table) { foreach ($this->connection->getSupplementalDriver()->getForeignKeys($table) as $row) { $this->structure['belongsTo'][strtolower($table)][$row['local']] = $row['table']; $this->structure['hasMany'][strtolower($row['table'])][$row['local'] . $table] = array($row['local'], $table); } if (isset($this->structure['belongsTo'][$table])) { uksort($this->structure['belongsTo'][$table], create_function('$a, $b', ' return strlen($a) - strlen($b); ')); } }
private function detectColumnTypes() { if ($this->types === NULL) { $this->types = array(); if ($this->connection->getSupplementalDriver()->supports['meta']) { // workaround for PHP bugs #53782, #54695 $col = 0; while ($meta = $this->getColumnMeta($col++)) { if (isset($meta['native_type'])) { $this->types[$meta['name']] = self::detectType($meta['native_type']); } } } } return $this->types; }
private function detectColumnTypes() { if ($this->types === NULL) { $this->types = array(); if ($this->connection->getSupplementalDriver()->isSupported(ISupplementalDriver::SUPPORT_COLUMNS_META)) { // workaround for PHP bugs #53782, #54695 $count = $this->columnCount(); for ($col = 0; $col < $count; $col++) { $meta = $this->getColumnMeta($col); if (isset($meta['native_type'])) { $this->types[$meta['name']] = NDatabaseHelpers::detectType($meta['native_type']); } } } } return $this->types; }
/** * @return string */ public function getPrimarySequence() { if ($this->primarySequence === FALSE) { $this->primarySequence = NULL; $driver = $this->connection->getSupplementalDriver(); if ($driver->isSupported(ISupplementalDriver::SUPPORT_SEQUENCE) && $this->primary !== NULL) { foreach ($driver->getColumns($this->name) as $column) { if ($column['name'] === $this->primary) { $this->primarySequence = $column['vendor']['sequence']; break; } } } } return $this->primarySequence; }
public function __construct(NConnection $connection) { $this->connection = $connection; $this->driver = $connection->getSupplementalDriver(); }