/** * @return array */ protected function getTables() { $tables = []; foreach ($this->structure->getTables() as $table) { if ($table['view'] === FALSE) { foreach ($this->structure->getColumns($table['name']) as $column) { $tables[$table['name']][$column['name']] = \Nette\Database\Helpers::detectType($column['nativetype']); } } } return $tables; }
/** * Returns associative array of detected types (IReflection::FIELD_*) in result set. */ public function getColumnTypes(\PDOStatement $statement) { $types = []; $count = $statement->columnCount(); for ($col = 0; $col < $count; $col++) { $meta = $statement->getColumnMeta($col); if (isset($meta['native_type'])) { $types[$meta['name']] = $type = Nette\Database\Helpers::detectType($meta['native_type']); if ($type === Nette\Database\IStructure::FIELD_TIME) { $types[$meta['name']] = Nette\Database\IStructure::FIELD_TIME_INTERVAL; } } } return $types; }
/** * Returns associative array of detected types (IReflection::FIELD_*) in result set. */ public function getColumnTypes(\PDOStatement $statement) { $types = []; $count = $statement->columnCount(); for ($col = 0; $col < $count; $col++) { $meta = $statement->getColumnMeta($col); if (isset($meta['sqlite:decl_type'])) { if ($meta['sqlite:decl_type'] === 'DATE') { $types[$meta['name']] = Nette\Database\IStructure::FIELD_UNIX_TIMESTAMP; } else { $types[$meta['name']] = Nette\Database\Helpers::detectType($meta['sqlite:decl_type']); } } elseif (isset($meta['native_type'])) { $types[$meta['name']] = Nette\Database\Helpers::detectType($meta['native_type']); } } return $types; }
private function detectColumnTypes() { if ($this->types === NULL) { $this->types = array(); if ($this->connection->getSupplementalDriver()->isSupported(ISupplementalDriver::SUPPORT_COLUMNS_META)) { $count = $this->columnCount(); for ($col = 0; $col < $count; $col++) { $meta = $this->getColumnMeta($col); if (isset($meta['native_type'])) { $this->types[$meta['name']] = Helpers::detectType($meta['native_type']); } } } } return $this->types; }
private function detectColumnTypes() { if ($this->types === null) { $this->types = array(); if ($this->connection->getSupplementalDriver()->isSupported(ISupplementalDriver::META)) { // workaround for PHP bugs #53782, #54695 $col = 0; while ($meta = $this->getColumnMeta($col++)) { if (isset($meta['native_type'])) { $this->types[$meta['name']] = Helpers::detectType($meta['native_type']); } } } } return $this->types; }
private function determineFromColumns(array $columns) { $out = []; foreach ($columns as $column) { $type = Nette\Database\Helpers::detectType($column['nativetype']); if ($column['nativetype'] === 'ENUM') { $out[$column['name']] = ['type' => IColumnStructure::ENUM]; $enum = $column['vendor']['Type']; $options = str_getcsv(str_replace('enum(', '', substr($enum, 0, strlen($enum) - 1)), ',', "'"); $out[$column['name']]['values'] = []; foreach ($options as $option) { $out[$column['name']]['values'][] = $option; } } elseif ($column['nativetype'] === 'TINYINT' && $column['size'] === 1) { $out[$column['name']] = ['type' => IColumnStructure::BOOL]; } else { switch ($type) { case Nette\Database\IStructure::FIELD_TEXT: $out[$column['name']] = ['type' => IColumnStructure::TEXT]; break; case Nette\Database\IStructure::FIELD_INTEGER: case Nette\Database\IStructure::FIELD_FLOAT: $out[$column['name']] = ['type' => IColumnStructure::NUMBER]; break; case Nette\Database\IStructure::FIELD_DATE: case Nette\Database\IStructure::FIELD_TIME: case Nette\Database\IStructure::FIELD_DATETIME: case Nette\Database\IStructure::FIELD_UNIX_TIMESTAMP: $out[$column['name']] = ['type' => IColumnStructure::DATE]; break; case Nette\Database\IStructure::FIELD_BOOL: $out[$column['name']] = ['type' => IColumnStructure::BOOL]; break; } } if (isset($out[$column['name']])) { $out[$column['name']]['nullable'] = $column['nullable']; } } return $out; }
Nette\DateTime($value);}}return$this->connection->getSupplementalDriver()->normalizeRow($row,$this);}private function detectColumnTypes(){if($this->types===NULL){$this->types=array();if($this->connection->getSupplementalDriver()->isSupported(ISupplementalDriver::META)){$col=0;while($meta=$this->getColumnMeta($col++)){if(isset($meta['native_type'])){$this->types[$meta['name']]=Helpers::detectType($meta['native_type']);}}}}return$this->types;}function
/** * Returns associative array of detected types (IReflection::FIELD_*) in result set. */ public function getColumnTypes(\PDOStatement $statement) { $types = array(); $count = $statement->columnCount(); for ($col = 0; $col < $count; $col++) { $meta = $statement->getColumnMeta($col); if (isset($meta['sqlsrv:decl_type']) && $meta['sqlsrv:decl_type'] !== 'timestamp') { // timestamp does not mean time in sqlsrv $types[$meta['name']] = Nette\Database\Helpers::detectType($meta['sqlsrv:decl_type']); } elseif (isset($meta['native_type'])) { $types[$meta['name']] = Nette\Database\Helpers::detectType($meta['native_type']); } } return $types; }