本文整理汇总了PHP中DataType::create方法的典型用法代码示例。如果您正苦于以下问题:PHP DataType::create方法的具体用法?PHP DataType::create怎么用?PHP DataType::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataType
的用法示例。
在下文中一共展示了DataType::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetList
public function testGetList()
{
$primitive = Primitive::enumeration('enum')->of('DataType');
$enum = DataType::create(DataType::getAnyId());
$this->assertEquals($primitive->getList(), $enum->getObjectList());
$primitive->setDefault($enum);
$this->assertEquals($primitive->getList(), $enum->getObjectList());
$primitive->import(array('enum' => DataType::getAnyId()));
$this->assertEquals($primitive->getList(), $enum->getObjectList());
}
示例2: DBSchema
<?php
/*****************************************************************************
* Copyright (C) 2006-2007, onPHP's MetaConfiguration Builder. *
* Generated by onPHP-0.9.128 at 2007-03-31 16:25:48 *
* This file is autogenerated - do not edit. *
*****************************************************************************/
$schema = new DBSchema();
$schema->addTable(DBTable::create('administrator')->addColumn(DBColumn::create(DataType::create(DataType::BIGINT)->setNull(false), 'id')->setPrimaryKey(true)->setAutoincrement(true))->addColumn(DBColumn::create(DataType::create(DataType::VARCHAR)->setNull(false)->setSize(64), 'username'))->addColumn(DBColumn::create(DataType::create(DataType::VARCHAR)->setNull(false)->setSize(40), 'password')));
示例3: getTableInfo
public function getTableInfo($table)
{
static $types = array('tinyint' => DataType::SMALLINT, 'smallint' => DataType::SMALLINT, 'int' => DataType::INTEGER, 'mediumint' => DataType::INTEGER, 'bigint' => DataType::BIGINT, 'double' => DataType::DOUBLE, 'decimal' => DataType::NUMERIC, 'char' => DataType::CHAR, 'varchar' => DataType::VARCHAR, 'text' => DataType::TEXT, 'tinytext' => DataType::TEXT, 'mediumtext' => DataType::TEXT, 'date' => DataType::DATE, 'time' => DataType::TIME, 'timestamp' => DataType::TIMESTAMP, 'datetime' => DataType::TIMESTAMP, 'set' => null, 'enum' => null, 'year' => null);
try {
$result = $this->queryRaw('SHOW COLUMNS FROM ' . $table);
} catch (BaseException $e) {
throw new ObjectNotFoundException("unknown table '{$table}'");
}
$table = new DBTable($table);
while ($row = mysql_fetch_assoc($result)) {
$name = strtolower($row['Field']);
$matches = array();
$info = array('type' => null, 'extra' => null);
if (preg_match('~(\\w+)(\\((\\d+?)\\)){0,1}\\s*(\\w*)~', strtolower($row['Type']), $matches)) {
$info['type'] = $matches[1];
$info['size'] = $matches[3];
$info['extra'] = $matches[4];
}
Assert::isTrue(array_key_exists($info['type'], $types), 'unknown type "' . $types[$info['type']] . '" found in column "' . $name . '"');
if (empty($types[$info['type']])) {
continue;
}
$column = DBColumn::create(DataType::create($types[$info['type']])->setUnsigned(strtolower($info['extra']) == 'unsigned')->setNull(strtolower($row['Null']) == 'yes'), $name)->setAutoincrement(strtolower($row['Extra']) == 'auto_increment')->setPrimaryKey(strtolower($row['Key']) == 'pri');
if ($row['Default']) {
$column->setDefault($row['Default']);
}
$table->addColumn($column);
}
return $table;
}
示例4: getTableInfo
/**
* @throws ObjectNotFoundException
* @return DBTable
**/
public function getTableInfo($table)
{
static $types = array('time' => DataType::TIME, 'date' => DataType::DATE, 'timestamp' => DataType::TIMESTAMP, 'bool' => DataType::BOOLEAN, 'int2' => DataType::SMALLINT, 'int4' => DataType::INTEGER, 'int8' => DataType::BIGINT, 'numeric' => DataType::NUMERIC, 'float4' => DataType::REAL, 'float8' => DataType::DOUBLE, 'varchar' => DataType::VARCHAR, 'bpchar' => DataType::CHAR, 'text' => DataType::TEXT, 'bytea' => DataType::BINARY, 'ip4' => DataType::IP, 'inet' => DataType::IP, 'ip4r' => DataType::IP_RANGE, 'tsvector' => null, 'ltree' => null, 'hstore' => null);
try {
$res = pg_meta_data($this->link, $table);
} catch (BaseException $e) {
throw new ObjectNotFoundException("unknown table '{$table}'");
}
$table = new DBTable($table);
foreach ($res as $name => $info) {
Assert::isTrue(array_key_exists($info['type'], $types), 'unknown type "' . $types[$info['type']] . '" found in column "' . $name . '"');
if (empty($types[$info['type']])) {
continue;
}
$column = new DBColumn(DataType::create($types[$info['type']])->setNull(!$info['not null']), $name);
$table->addColumn($column);
}
return $table;
}
示例5: getSeriesGenerator
/**
* @return DialectString
*
* FIXME: DBI-result, method works only for PostgreSQL.
* Research how to generate series of values in MySQL and implement
* this.
**/
private function getSeriesGenerator($start, $stop, $step = null)
{
if (!$step) {
$result = SQLFunction::create('generate_series', DBValue::create($start)->castTo(DataType::create(DataType::INTEGER)->getName()), DBValue::create($stop)->castTo(DataType::create(DataType::INTEGER)->getName()));
} else {
$result = SQLFunction::create('generate_series', DBValue::create($start)->castTo(DataType::create(DataType::INTEGER)->getName()), DBValue::create($stop)->castTo(DataType::create(DataType::INTEGER)->getName()), DBValue::create($step)->castTo(DataType::create(DataType::INTEGER)->getName()));
}
return $result;
}