本文整理汇总了PHP中Column类的典型用法代码示例。如果您正苦于以下问题:PHP Column类的具体用法?PHP Column怎么用?PHP Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Column类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setDefaultSortColumn
public function setDefaultSortColumn(Column $col, $direction = false)
{
if ($direction != false) {
$col->setColumnDefaultSortDirection($direction);
}
$this->defaultSortColumn = $col;
}
开发者ID:digideskio,项目名称:concrete5,代码行数:7,代码来源:Set.php
示例2: removeSubColumn
public function removeSubColumn(Column $column)
{
$this->subColumns = array_values(array_filter($this->subColumns, function ($elm) use($column) {
return $elm->getName() !== $column->getName();
}));
return $this;
}
开发者ID:brodaproject,项目名称:broda,代码行数:7,代码来源:Column.php
示例3: create_column
public function create_column(&$column)
{
$c = new Column();
$c->inflected_name = Inflector::instance()->variablize($column['field']);
$c->name = $column['field'];
$c->nullable = $column['null'] === 'YES' ? true : false;
$c->pk = $column['key'] === 'PRI' ? true : false;
$c->auto_increment = $column['extra'] === 'auto_increment' ? true : false;
if ($column['type'] == 'timestamp' || $column['type'] == 'datetime') {
$c->raw_type = 'datetime';
$c->length = 19;
} elseif ($column['type'] == 'date') {
$c->raw_type = 'date';
$c->length = 10;
} else {
preg_match('/^([A-Za-z0-9_]+)(\\(([0-9]+(,[0-9]+)?)\\))?/', $column['type'], $matches);
$c->raw_type = count($matches) > 0 ? $matches[1] : $column['type'];
if (count($matches) >= 4) {
$c->length = intval($matches[3]);
}
}
$c->map_raw_type();
$c->default = $c->cast($column['default']);
return $c;
}
开发者ID:469306621,项目名称:Languages,代码行数:25,代码来源:MysqlAdapter.php
示例4: addColumns
/**
* Adds Columns to the specified table.
*
* @param Table $table The Table model class to add columns to.
*/
protected function addColumns(Table $table)
{
$stmt = $this->dbh->query("sp_columns '" . $table->getName() . "'");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = $row['COLUMN_NAME'];
$type = $row['TYPE_NAME'];
$size = $row['LENGTH'];
$is_nullable = $row['NULLABLE'];
$default = $row['COLUMN_DEF'];
$precision = $row['PRECISION'];
$scale = $row['SCALE'];
$autoincrement = false;
if (strtolower($type) == "int identity") {
$autoincrement = true;
}
$propelType = $this->getMappedPropelType($type);
if (!$propelType) {
$propelType = Column::DEFAULT_TYPE;
$this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support.");
}
$column = new Column($name);
$column->setTable($table);
$column->setDomainForType($propelType);
// We may want to provide an option to include this:
// $column->getDomain()->replaceSqlType($type);
$column->getDomain()->replaceSize($size);
$column->getDomain()->replaceScale($scale);
if ($default !== null) {
$column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
}
$column->setAutoIncrement($autoincrement);
$column->setNotNull(!$is_nullable);
$table->addColumn($column);
}
}
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:40,代码来源:MssqlSchemaParser.php
示例5: populateFromOptions
protected function populateFromOptions($options)
{
foreach ($options as $name => $attrs) {
$column = new Column($name);
if (isset($attrs['field'])) {
$column->setFieldName($attrs['field']);
}
if (isset($attrs['type'])) {
$column->setType($attrs['type']);
}
if (isset($attrs['sortable'])) {
$column->setSortable($attrs['sortable']);
}
if (isset($attrs['label'])) {
$column->setLabel($attrs['label']);
}
if (isset($attrs['format'])) {
$column->setFormat($attrs['format']);
}
if (isset($attrs['format_function'])) {
$column->setFormatFunction($attrs['format_function']);
}
if (isset($attrs['template'])) {
$column->setTemplate($attrs['template']);
}
if (isset($attrs['boolean_actions'])) {
$column->setBooleanActions($attrs['boolean_actions']);
}
if (isset($attrs['get_methods'])) {
$column->setMethods($attrs['get_methods']);
}
$this->add($column);
}
}
开发者ID:senthilkumar3282,项目名称:LyraAdminBundle,代码行数:34,代码来源:ColumnCollection.php
示例6: createColumn
public function createColumn(&$column)
{
$c = new Column();
$c->inflectedName = Inflector::instance()->variablize($column['field']);
$c->name = $column['field'];
$c->nullable = $column['not_nullable'] ? false : true;
$c->pk = $column['pk'] ? true : false;
$c->autoIncrement = false;
if (substr($column['type'], 0, 9) == 'timestamp') {
$c->rawType = 'datetime';
$c->length = 19;
} elseif ($column['type'] == 'date') {
$c->rawType = 'date';
$c->length = 10;
} else {
preg_match('/^([A-Za-z0-9_]+)(\\(([0-9]+(,[0-9]+)?)\\))?/', $column['type'], $matches);
$c->rawType = count($matches) > 0 ? $matches[1] : $column['type'];
$c->length = count($matches) >= 4 ? intval($matches[3]) : intval($column['attlen']);
if ($c->length < 0) {
$c->length = null;
}
}
$c->mapRawType();
if ($column['default']) {
preg_match('/^nextval\\(\'(.*)\'\\)$/', $column['default'], $matches);
if (count($matches) == 2) {
$c->sequence = $matches[1];
} else {
$c->default = $c->cast($column['default'], $this);
}
}
return $c;
}
开发者ID:ruri,项目名称:php-activerecord-camelcased,代码行数:33,代码来源:PgsqlAdapter.php
示例7: testReplaceColumnWithoutReplacement
public function testReplaceColumnWithoutReplacement()
{
$xml = '<?xml version="1.0" ?>
<column name="test" dump="replace" />';
$xmlElement = new \SimpleXMLElement($xml);
$columnConfig = new Column($xmlElement);
$this->assertEquals('', $columnConfig->processRowValue('test value'));
}
开发者ID:webfactory,项目名称:slimdump,代码行数:8,代码来源:ColumnTest.php
示例8: createEnumColumn
public function createEnumColumn($defaultValues, $defaultValue)
{
$column = new Column();
$column->setType(PropelTypes::ENUM);
$column->setValueSet($defaultValues);
$column->setDefaultValue($defaultValue);
return $column;
}
开发者ID:ketheriel,项目名称:ETVA,代码行数:8,代码来源:DefaultPlatformTest.php
示例9: columnName
/**
*
* @return database.model.Column
*/
function columnName()
{
if (!Rhaco::isVariable("_R_D_C_", "Category::Name")) {
$column = new Column("column=name,variable=name,type=string,size=30,require=true,", __CLASS__);
$column->label(Message::_("name"));
Rhaco::addVariable("_R_D_C_", $column, "Category::Name");
}
return Rhaco::getVariable("_R_D_C_", null, "Category::Name");
}
开发者ID:riaf,项目名称:concert,代码行数:13,代码来源:CategoryTable.php
示例10: add_column
public function add_column($name, $cfg)
{
$col = new Column($this, $name);
if (!$col->exists()) {
$col->set_cfg($cfg);
$this->columns[$name] = $col;
return $col;
} else {
throw new \System\Error\Database(sprintf("Column '%s' already exists in table '%s'", $name, $this->name));
}
}
开发者ID:just-paja,项目名称:fudjan,代码行数:11,代码来源:table.php
示例11: __construct
/**
* @api
* @since 1.0.0
*
* @param DataTable\Column $column
* @param integer|string|\DateTime $value
* @param string $label
* @throws InvalidArgumentException if the supplied value is not of the supplied column's data type
* @throws InvalidArgumentException if the supplied label is not a string
*/
public function __construct(Column $column, $value, $label = '')
{
$this->column = $column;
if (!$this->column->isValueValidType($value)) {
throw new \InvalidArgumentException("'{$value}' is not of type '{$column->getType()}'!");
}
if (!is_string($label)) {
throw new \InvalidArgumentException("The cell label must be a string!");
}
$this->value = $value;
$this->label = $label;
}
开发者ID:zachgarwood,项目名称:datatable,代码行数:22,代码来源:Cell.php
示例12: create
public function create($name, $configures = NULL)
{
$column = new Column();
if (!empty($configures)) {
if (is_array($configures)) {
$column->set($configures);
}
}
$column->set("name", $name);
$this->add($column);
return $column;
}
开发者ID:elsewise,项目名称:gridded,代码行数:12,代码来源:ColumnBuilder.php
示例13: readHeader
protected function readHeader()
{
$this->version = $this->readChar();
$this->foxpro = $this->version == 48 || $this->version == 49 || $this->version == 245 || $this->version == 251;
$this->modifyDate = $this->read3ByteDate();
$this->recordCount = $this->readInt();
$this->headerLength = $this->readShort();
$this->recordByteLength = $this->readShort();
$this->readBytes(2);
//reserved
$this->inTransaction = $this->readByte() != 0;
$this->encrypted = $this->readByte() != 0;
$this->readBytes(4);
//Free record thread
$this->readBytes(8);
//Reserved for multi-user dBASE
$this->mdxFlag = $this->readByte();
$this->languageCode = $this->readByte();
$this->readBytes(2);
//reserved
$fieldCount = floor(($this->headerLength - ($this->foxpro ? 296 : 33)) / 32);
/* some checking */
if ($this->headerLength > filesize($this->tableName)) {
throw new Exception\TableException(sprintf('File %s is not DBF', $this->tableName));
}
if ($this->headerLength + $this->recordCount * $this->recordByteLength - 500 > filesize($this->tableName)) {
throw new Exception\TableException(sprintf('File %s is not DBF', $this->tableName));
}
/* columns */
$this->columns = array();
$bytepos = 1;
$j = 0;
for ($i = 0; $i < $fieldCount; $i++) {
$column = new Column(strtolower($this->readString(11)), $this->readByte(), $this->readInt(), $this->readChar(), $this->readChar(), $this->readBytes(2), $this->readChar(), $this->readBytes(2), $this->readByte() != 0, $this->readBytes(7), $this->readByte() != 0, $j, $bytepos);
$bytepos += $column->getLength();
if (!$this->avaliableColumns || $this->avaliableColumns && in_array($column->name, $this->avaliableColumns)) {
$this->addColumn($column);
$j++;
}
}
if ($this->foxpro) {
$this->backlist = $this->readBytes(263);
}
$this->setFilePos($this->headerLength);
$this->recordPos = -1;
$this->record = false;
$this->deleteCount = 0;
}
开发者ID:caiweiming,项目名称:php-xbase,代码行数:48,代码来源:Table.php
示例14: testFactories
public function testFactories()
{
// char
$this->assertEquals(new CharColumn('foo', 'char', 0), Column::char('foo', 0));
$this->assertEquals(new CharColumn('foo', 'varchar', 0), Column::varchar('foo', 0));
// datetime
$this->assertEquals(new DateTimeColumn('foo'), Column::datetime('foo'));
// decimal
$this->assertEquals(new DecimalColumn('foo', 10, 2), Column::decimal('foo', 10, 2));
// float
$this->assertEquals(new FloatColumn('foo', 10, 2), Column::float('foo', 10, 2));
// int
$this->assertEquals(new IntColumn('foo', 'tinyint'), Column::tinyint('foo'));
$this->assertEquals(new IntColumn('foo', 'smallint'), Column::smallint('foo'));
$this->assertEquals(new IntColumn('foo', 'int'), Column::int('foo'));
$this->assertEquals(new IntColumn('foo', 'mediumint'), Column::mediumint('foo'));
$this->assertEquals(new IntColumn('foo', 'bigint'), Column::bigint('foo'));
$this->assertEquals((new IntColumn('foo', 'tinyint'))->setUnsigned()->setAutoIncrement(), Column::tinyserial('foo'));
$this->assertEquals((new IntColumn('foo', 'smallint'))->setUnsigned()->setAutoIncrement(), Column::smallserial('foo'));
$this->assertEquals((new IntColumn('foo', 'int'))->setUnsigned()->setAutoIncrement(), Column::serial('foo'));
$this->assertEquals((new IntColumn('foo', 'mediumint'))->setUnsigned()->setAutoIncrement(), Column::mediumserial('foo'));
$this->assertEquals((new IntColumn('foo', 'bigint'))->setUnsigned()->setAutoIncrement(), Column::bigserial('foo'));
// text
$this->assertEquals(new TextColumn('foo', 'tinytext'), Column::tinytext('foo'));
$this->assertEquals(new TextColumn('foo', 'text'), Column::text('foo'));
$this->assertEquals(new TextColumn('foo', 'mediumtext'), Column::mediumtext('foo'));
$this->assertEquals(new TextColumn('foo', 'longtext'), Column::longtext('foo'));
// timestamp
$this->assertEquals(new TimestampColumn('foo'), Column::timestamp('foo'));
}
开发者ID:vegvari,项目名称:AliusDatabase,代码行数:30,代码来源:ColumnTest.php
示例15: columns
public function columns($cb)
{
Column::reset();
call_user_func($cb);
$this->column = Column::get();
return $this;
}
开发者ID:hugofabricio,项目名称:laravel-crud,代码行数:7,代码来源:AdminItem.php
示例16: checkConstraints
public function checkConstraints($target)
{
parent::checkConstraints($target);
if (is_null($this->className) && is_null($this->name)) {
throw new \Exception("L'un des attributs className ou name est obligatoire pour une annotation de type JoinColumn");
}
}
开发者ID:nicolasBREYNAERT,项目名称:helpdesk,代码行数:7,代码来源:JoinColumn.php
示例17: getInstance
private static function getInstance()
{
if (empty(self::$instance)) {
self::$instance = new Column();
}
return self::$instance;
}
开发者ID:hugofabricio,项目名称:laravel-crud,代码行数:7,代码来源:Column.php
示例18: __call
public function __call($method, $arguments)
{
if ($method === 'index' || array_key_exists($method, Column::$TYPES)) {
if (count($arguments) <= 0) {
throw new MissingArgumentException($method, __CLASS__);
}
$column = $arguments[0];
$options = !empty($arguments[1]) ? $arguments[1] : array();
if ($method === 'index') {
if (!is_array($column)) {
$column = array($column);
}
$this->indexes = array_merge($this->indexes, array(array('name' => Index::instance()->getName($column, $options), 'keys' => '`' . implode('`,`', $column) . '`')));
} else {
$options['id'] = $column;
$options['type'] = $method;
$this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase($options)));
}
} else {
if ($method === 'timestamps') {
$this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase(array('id' => 'created_at', 'type' => 'datetime'))));
$this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase(array('id' => 'updated_at', 'type' => 'datetime'))));
} else {
throw new UndefinedMethodException($method, __CLASS__);
}
}
}
开发者ID:nanjingboy,项目名称:clown,代码行数:27,代码来源:Table.php
示例19: getDefaultValueStringProvider
public static function getDefaultValueStringProvider()
{
$col1 = new Column('Bar');
$col1->setDomain(new Domain('VARCHAR'));
$col1->setDefaultValue(new ColumnDefaultValue('abc', ColumnDefaultValue::TYPE_VALUE));
$val1 = "'abc'";
$col2 = new Column('Bar');
$col2->setDomain(new Domain('INTEGER'));
$col2->setDefaultValue(new ColumnDefaultValue(1234, ColumnDefaultValue::TYPE_VALUE));
$val2 = "1234";
$col3 = new Column('Bar');
$col3->setDomain(new Domain('DATE'));
$col3->setDefaultValue(new ColumnDefaultValue('0000-00-00', ColumnDefaultValue::TYPE_VALUE));
$val3 = "NULL";
return array(array($col1, $val1), array($col2, $val2), array($col3, $val3));
}
开发者ID:shelsonjava,项目名称:datawrapper,代码行数:16,代码来源:PHP5ObjectBuilderTest.php
示例20: setDefault
public function setDefault($value) : Column
{
if ($this->isAutoIncrement()) {
throw new ColumnException('Auto increment column can\'t have default value');
}
return parent::setDefault($value);
}
开发者ID:vegvari,项目名称:AliusDatabase,代码行数:7,代码来源:IntColumn.php
注:本文中的Column类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论