本文整理汇总了PHP中Dataface_Table::_newSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP Dataface_Table::_newSchema方法的具体用法?PHP Dataface_Table::_newSchema怎么用?PHP Dataface_Table::_newSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataface_Table
的用法示例。
在下文中一共展示了Dataface_Table::_newSchema方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Returns an associative array of field definitions for this view.
*/
function &fields()
{
// check the cache first.
if (isset($this->_cache[__FUNCTION__])) {
return $this->_cache[__FUNCTION__];
}
// it is not in the cache yet, let's calculate it.
$out = array();
$data = $this->_parseSQL();
$this->_expandGlobs($data);
$numCols = count($data['columns']);
for ($i = 0; $i < $numCols; $i++) {
$column = $data['columns'][$i];
if ($column['type'] == 'ident') {
// This column is just a normal column that is drawn from a table.
// vs. the alternative which is a function.
if ($column['table']) {
$table =& $this->getTableOrView($column['table']);
} else {
if ($column['alias']) {
$key = $column['alias'];
} else {
$key = $column['value'];
}
$tablename = $this->guessColumnTableName($key);
$table =& $this->getTableOrView($tablename);
}
$out[$key] =& $table->getField($key);
unset($table);
} else {
$out[$column['alias']] = Dataface_Table::_newSchema($column['type'], $column['alias'], $this->name);
}
}
$this->_cache[__FUNCTION__] =& $out;
$this->_fields =& $out;
return $out;
}
示例2: array
/**
* Adds a field to this table.
* @param array $field A partial field definition. Must contain at least
* Field (or name) and Type keys.
* @param string $field[Field] The name of the field
* @param string $field[Type] The type of the field (e.g. int(11))
* @param string $field[Default] The default value
* @param string $field[Key] 'PRI' if this is part of the primary key.
* @param string $field[Null] Empty if the field is not null.
* @return array The finished field definition.
*/
function &addField($field)
{
if (!isset($field['Field']) and !isset($field['name'])) {
$err = PEAR::raiseError("Attempt to add field that has no name.");
return $err;
}
if (!isset($field['Field'])) {
$field['Field'] = $field['name'];
}
if (!isset($field['name'])) {
$field['name'] = $field['Field'];
}
$schema = Dataface_Table::_newSchema($field['Type'], $field['name'], $this->name);
$fields =& $this->fields();
$fields[$field['name']] =& $schema;
$conf = array();
$this->flattenConfigArray($field, $conf);
foreach (array_keys($conf) as $key) {
$this->setParameter($field['name'], $key, $conf[$key]);
}
return $conf;
}