/** * Add the field to the underlying database. * * @see DBField::requireField() */ public function requireField() { //@todo change this to use Link rather than basic varchar $parts = array('datatype' => 'varchar', 'precision' => 50, 'character set' => 'utf8', 'default' => 0, 'arrayValue' => $this->arrayValue); $values = array('type' => 'varchar', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
public function requireField() { $fields = $this->compositeDatabaseFields(); if ($fields) { foreach ($fields as $name => $type) { \DB::requireField($this->tableName, $this->name . $name, $type); } } }
public function requireField() { // HACK: MSSQL does not support double so we're usinf float instead // @todo This should go into MSSQLDatabase ideally somehow if (DB::getConn() instanceof MySQLDatabase) { DB::requireField($this->tableName, $this->name, "double"); } else { DB::requireField($this->tableName, $this->name, "float"); } }
/** * (non-PHPdoc) * @see DBField::requireField() */ public function requireField() { $parts = array('datatype' => 'varchar', 'precision' => 9, 'character set' => 'utf8', 'collate' => 'utf8_general_ci', 'arrayValue' => $this->arrayValue); $values = array('type' => 'varchar', 'parts' => $parts); // Add support for both SS DB API 3.2 and <3.2 if (method_exists('DB', 'require_field')) { DB::require_field($this->tableName, $this->name, $values); } else { DB::requireField($this->tableName, $this->name, $values); } }
/** * (non-PHPdoc) * @see DBField::requireField() */ function requireField() { $parts = array( 'datatype'=>'varchar', 'precision'=>$this->size, 'character set'=>'utf8', 'collate'=>'utf8_general_ci', 'arrayValue'=>$this->arrayValue ); $values = array( 'type' => 'varchar', 'parts' => $parts ); DB::requireField($this->tableName, $this->name, $values); }
/** * Compose the requirements for this field * * Note: Issue with this approach is if the same name is used in different relations, * believe this is a limitation with SilverStripe anyway. * many_many = array('Name' => 'SomeClass') * belongs_many_many = array('Name' => 'SomeOtherClass') * * @return void */ public function requireField() { //Get the type of object for this relation and pass to OrientDatabase::linkset() effectively //@todo @has_many same treatment for has_many //@todo @belongs_many_many same treatment for belongs_many_many $relationClass = null; //Does the tableName always match the class name? $manyMany = Config::inst()->get($this->tableName, 'many_many', Config::UNINHERITED); if (isset($manyMany[$this->name])) { $relationClass = $manyMany[$this->name]; } $belongsManyMany = Config::inst()->get($this->tableName, 'belongs_many_many', Config::UNINHERITED); if (isset($belongsManyMany[$this->name])) { $relationClass = $belongsManyMany[$this->name]; } //If the relation class cannot be found do not create the linkset at all if (!$relationClass) { return; } $parts = array('datatype' => 'linkset', 'precision' => null, 'null' => null, 'default' => null, 'arrayValue' => null, 'relationClass' => $relationClass); $values = array('type' => 'linkset', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
function augmentDatabase() { $classTable = $this->owner->class; // Build a list of suffixes whose tables need versioning $allSuffixes = array(); foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) { if ($this->owner->hasExtension($versionableExtension) && singleton($versionableExtension)->stat('enabled')) { $allSuffixes = array_merge($allSuffixes, (array) $suffixes); foreach ((array) $suffixes as $suffix) { $allSuffixes[$suffix] = $versionableExtension; } } } // Add the default table with an empty suffix to the list (table name = class name) array_push($allSuffixes, ''); foreach ($allSuffixes as $key => $suffix) { // check that this is a valid suffix if (!is_int($key)) { continue; } if ($suffix) { $table = "{$classTable}_{$suffix}"; } else { $table = $classTable; } if ($fields = $this->owner->databaseFields()) { $indexes = $this->owner->databaseIndexes(); if ($this->owner->parentClass() == "DataObject") { $rootTable = true; } if ($suffix && ($ext = $this->owner->extInstance($allSuffixes[$suffix]))) { if (!$ext->isVersionedTable($table)) { continue; } $fields = $ext->fieldsInExtraTables($suffix); $indexes = $fields['indexes']; $fields = $fields['db']; } // Create tables for other stages foreach ($this->stages as $stage) { // Extra tables for _Live, etc. if ($stage != $this->defaultStage) { DB::requireTable("{$table}_{$stage}", $fields, $indexes); /* if(!DB::query("SELECT * FROM {$table}_$stage")->value()) { $fieldList = implode(", ",array_keys($fields)); DB::query("INSERT INTO `{$table}_$stage` (ID,$fieldList) SELECT ID,$fieldList FROM `$table`"); } */ } // Version fields on each root table (including Stage) if (isset($rootTable)) { $stageTable = $stage == $this->defaultStage ? $table : "{$table}_{$stage}"; DB::requireField($stageTable, "Version", "int(11) not null default '0'"); } } // Create table for all versions $versionFields = array_merge(array("RecordID" => "Int", "Version" => "Int", "WasPublished" => "Boolean", "AuthorID" => "Int", "PublisherID" => "Int"), (array) $fields); $versionIndexes = array_merge(array('RecordID_Version' => '(RecordID, Version)', 'RecordID' => true, 'Version' => true, 'AuthorID' => true, 'PublisherID' => true), (array) $indexes); DB::requireTable("{$table}_versions", $versionFields, $versionIndexes); /* if(!DB::query("SELECT * FROM {$table}_versions")->value()) { $fieldList = implode(", ",array_keys($fields)); DB::query("INSERT INTO `{$table}_versions` ($fieldList, RecordID, Version) SELECT $fieldList, ID AS RecordID, 1 AS Version FROM `$table`"); } */ } else { DB::dontRequireTable("{$table}_versions"); foreach ($this->stages as $stage) { if ($stage != $this->defaultStage) { DB::dontrequireTable("{$table}_{$stage}"); } } } } }
function requireField() { DB::requireField($this->tableName, $this->name, "float"); }
function requireField() { DB::requireField($this->tableName, $this->name, "decimal({$this->wholeSize},{$this->decimalSize}) not null"); }
public function requireField() { $parts = array('datatype' => 'longblob', 'arrayValue' => $this->arrayValue); $values = array('type' => 'longblob', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values, $this->default); }
function requireField() { $parts = array('datatype' => 'int', 'precision' => 11, 'null' => 'not null', 'default' => $this->defaultVal, 'arrayValue' => $this->arrayValue); $values = array('type' => 'int', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
function requireField() { DB::requireField($this->tableName, $this->name, "tinyint(1) unsigned not null default '{$this->defaultVal}'"); }
function requireField() { DB::requireField($this->tableName, $this->name, "varchar({$this->size}) character set utf8 collate utf8_general_ci"); }
function requireField() { DB::requireField($this->tableName, $this->name, "year(4)"); }
public function requireField() { $parts = array('datatype' => 'year', 'precision' => 4, 'arrayValue' => $this->arrayValue); $values = array('type' => 'year', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
/** * Add the field to the underlying database. */ public function requireField() { DB::requireField($this->tableName, $this->name, 'mediumblob'); }
function augmentDatabase() { $classTable = $this->owner->class; $isRootClass = $this->owner->class == ClassInfo::baseDataClass($this->owner->class); // Build a list of suffixes whose tables need versioning $allSuffixes = array(); foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) { if ($this->owner->hasExtension($versionableExtension) && singleton($versionableExtension)->stat('enabled')) { $allSuffixes = array_merge($allSuffixes, (array) $suffixes); foreach ((array) $suffixes as $suffix) { $allSuffixes[$suffix] = $versionableExtension; } } } // Add the default table with an empty suffix to the list (table name = class name) array_push($allSuffixes, ''); foreach ($allSuffixes as $key => $suffix) { // check that this is a valid suffix if (!is_int($key)) { continue; } if ($suffix) { $table = "{$classTable}_{$suffix}"; } else { $table = $classTable; } if ($fields = $this->owner->databaseFields()) { $indexes = $this->owner->databaseIndexes(); if ($suffix && ($ext = $this->owner->extInstance($allSuffixes[$suffix]))) { if (!$ext->isVersionedTable($table)) { continue; } $fields = $ext->fieldsInExtraTables($suffix); $indexes = $fields['indexes']; $fields = $fields['db']; } // Create tables for other stages foreach ($this->stages as $stage) { // Extra tables for _Live, etc. if ($stage != $this->defaultStage) { DB::requireTable("{$table}_{$stage}", $fields, $indexes); } // Version fields on each root table (including Stage) if ($isRootClass) { $stageTable = $stage == $this->defaultStage ? $table : "{$table}_{$stage}"; DB::requireField($stageTable, "Version", "int(11) not null default '0'"); } } if ($isRootClass) { // Create table for all versions $versionFields = array_merge(array("RecordID" => "Int", "Version" => "Int", "WasPublished" => "Boolean", "AuthorID" => "Int", "PublisherID" => "Int"), (array) $fields); $versionIndexes = array_merge(array('RecordID_Version' => '(RecordID, Version)', 'RecordID' => true, 'Version' => true, 'AuthorID' => true, 'PublisherID' => true), (array) $indexes); } else { // Create fields for any tables of subclasses $versionFields = array_merge(array("RecordID" => "Int", "Version" => "Int"), (array) $fields); $versionIndexes = array_merge(array('RecordID_Version' => '(RecordID, Version)', 'RecordID' => true, 'Version' => true), (array) $indexes); } DB::requireTable("{$table}_versions", $versionFields, $versionIndexes); } else { DB::dontRequireTable("{$table}_versions"); foreach ($this->stages as $stage) { if ($stage != $this->defaultStage) { DB::dontrequireTable("{$table}_{$stage}"); } } } } }
function requireField() { DB::requireField($this->tableName, $this->name, "linestring"); }
function requireField() { $parts = array('datatype' => 'date', 'arrayValue' => $this->arrayValue); $values = array('type' => 'date', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
function requireField() { $values = array('type' => 'set', 'parts' => array('enums' => $this->enum, 'character set' => 'utf8', 'collate' => 'utf8_general_ci', 'default' => Convert::raw2sql($this->default), 'table' => $this->tableName, 'arrayValue' => $this->arrayValue)); DB::requireField($this->tableName, $this->name, $values); }
function requireField() { DB::requireField($this->tableName, $this->name, "double"); }
public function requireField() { $parts = array('datatype' => 'tinyint', 'precision' => 1, 'sign' => 'unsigned', 'null' => 'not null', 'default' => $this->defaultVal, 'arrayValue' => $this->arrayValue); $values = array('type' => 'boolean', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
function requireField(){ DB::requireField($this->tableName, $this->name, "enum('" . implode("','", $this->enum) . "') character set utf8 collate utf8_general_ci default '{$this->default}'"); }
function requireField() { DB::requireField($this->tableName, $this->name, "polygon"); }
function requireField() { $parts = array('datatype' => 'decimal', 'precision' => "{$this->wholeSize},{$this->decimalSize}", 'default' => (double) $this->defaultValue, 'arrayValue' => $this->arrayValue); $values = array('type' => 'decimal', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
/** * (non-PHPdoc) * @see DBField::requireField() */ public function requireField() { $parts = array('datatype' => 'mediumtext', 'character set' => 'utf8', 'collate' => 'utf8_general_ci', 'arrayValue' => $this->arrayValue); $values = array('type' => 'text', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values, $this->default); }
function requireField() { DB::requireField($this->tableName, $this->name, "mediumtext character set utf8 collate utf8_general_ci"); }
function requireField() { $parts = array('datatype' => 'enum', 'enums' => $this->enum, 'character set' => 'utf8', 'collate' => 'utf8_general_ci', 'default' => $this->default, 'table' => $this->tableName, 'arrayValue' => $this->arrayValue); $values = array('type' => 'enum', 'parts' => $parts); DB::requireField($this->tableName, $this->name, $values); }
public function requireField() { foreach ($this->compositeDatabaseFields() as $field => $spec) { $key = $this->getName() . $field; DB::requireField($this->tableName, $key, $spec); } }
function requireField() { DB::requireField($this->tableName, $this->name, "int(11) not null default '{$this->defaultVal}'"); }