本文整理汇总了PHP中Nette\Database\Helpers::detectType方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::detectType方法的具体用法?PHP Helpers::detectType怎么用?PHP Helpers::detectType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Helpers
的用法示例。
在下文中一共展示了Helpers::detectType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTables
/**
* @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;
}
示例2: getColumnTypes
/**
* 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;
}
示例3: getColumnTypes
/**
* 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;
}
示例4: detectColumnTypes
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;
}
示例5: detectColumnTypes
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;
}
示例6: determineFromColumns
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;
}
示例7:
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
示例8: getColumnTypes
/**
* 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;
}