本文整理汇总了PHP中ezcDbSchema::createNewTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcDbSchema::createNewTable方法的具体用法?PHP ezcDbSchema::createNewTable怎么用?PHP ezcDbSchema::createNewTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcDbSchema
的用法示例。
在下文中一共展示了ezcDbSchema::createNewTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processSchema
/**
* Loops over all the table names in the array and extracts schema
* information.
*
* This method extracts information about a database's schema from the
* database itself and returns this schema as an ezcDbSchema object.
*
* @param array(string) $tables
* @return ezcDbSchema
*/
protected function processSchema(array $tables)
{
$schemaDefinition = array();
array_walk($tables, create_function('&$item,$key', '$item = $item[0];'));
// strip out the prefix and only return tables with the prefix set.
$prefix = ezcDbSchema::$options->tableNamePrefix;
foreach ($tables as $tableName) {
$tableNameWithoutPrefix = substr($tableName, strlen($prefix));
// Process table if there was no prefix, or when a prefix was
// found. In the latter case the prefix would be missing from
// $tableNameWithoutPrefix due to the substr() above, and hence,
// $tableName and $tableNameWithoutPrefix would be different.
if ($prefix === '' || $tableName !== $tableNameWithoutPrefix) {
$fields = $this->fetchTableFields($tableName);
$indexes = $this->fetchTableIndexes($tableName);
$schemaDefinition[$tableNameWithoutPrefix] = ezcDbSchema::createNewTable($fields, $indexes);
}
}
return $schemaDefinition;
}
示例2: parseTable
/**
* Extracts information about a table from the XML element $table
*
* @param SimpleXMLElement $table
*
* @return ezcDbSchemaTable or an inherited class
*/
private function parseTable(SimpleXMLElement $table)
{
$fields = array();
$indexes = array();
foreach ($table->declaration->field as $field) {
$fieldName = (string) $field->name;
$fields[$fieldName] = $this->parseField($field);
}
foreach ($table->declaration->index as $index) {
$indexName = (string) $index->name;
$indexes[$indexName] = $this->parseIndex($index);
}
return ezcDbSchema::createNewTable($fields, $indexes);
}