本文整理汇总了PHP中ActiveRecord::getSchemaInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getSchemaInstance方法的具体用法?PHP ActiveRecord::getSchemaInstance怎么用?PHP ActiveRecord::getSchemaInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::getSchemaInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($className, $fieldName, $tableAlias = false)
{
$schema = ActiveRecord::getSchemaInstance($className);
if ($schema->fieldExists($fieldName)) {
$this->tableName = $tableAlias ? $tableAlias : $schema->getName();
$this->field = $schema->getField($fieldName);
} else {
throw new ARException("Unable to find defined schema or field: " . $className . "." . $fieldName);
}
}
示例2: getNewsPostEntry
private function getNewsPostEntry($row, $params)
{
$row['title'] = unserialize($row['title']);
$row = MultilingualObject::transformArray($row, ActiveRecord::getSchemaInstance('NewsPost'));
return array('loc' => $this->router->createFullUrl(createNewsPostUrl(array('news' => $row), $this->application)));
}
示例3: registerAutoReference
public function registerAutoReference($fieldName)
{
$foreignClassName = $this->getField($fieldName)->getForeignClassName();
$this->autoReferences[] = $foreignClassName;
$this->autoReferencedSchemas[] = ActiveRecord::getSchemaInstance($foreignClassName);
}
示例4: _generateTableDDL
protected function _generateTableDDL($name, $intent = "")
{
$comma = ", " . $intent;
$schema = ActiveRecord::getSchemaInstance($name);
$table_name = $schema->getName();
$field_list = $schema->GetFieldList();
$primary_list = $schema->getPrimaryKeyList();
$foreign_list = $schema->getForeignKeyList();
if (count($field_list) < 1) {
return null;
}
if (count($primary_list) > 1) {
$auto_increment = false;
} else {
$auto_increment = true;
}
$sql = "CREATE TABLE " . $table_name . " ( " . $intent;
// fields
foreach ($field_list as $field) {
$sql .= $field->getName() . " " . $this->_defineField($field, $auto_increment) . $comma;
//foreign key
if ($field instanceof ARForeignKeyField) {
$sql .= " FOREIGN KEY ( " . $field->getName() . " ) REFERENCES " . $field->getForeignTableName() . "( " . $field->getForeignFieldName() . " ) " . $comma;
}
}
//primary keys
if (count($primary_list) > 0) {
$sql .= " PRIMARY KEY ( ";
foreach ($primary_list as $primary) {
$sql .= $primary->getName() . $comma;
}
$sql = substr($sql, 0, -strlen($comma));
$sql .= " )" . $comma;
}
$sql = substr($sql, 0, -strlen($comma));
return $sql . " )";
}