本文整理汇总了PHP中Jelly::meta_alias方法的典型用法代码示例。如果您正苦于以下问题:PHP Jelly::meta_alias方法的具体用法?PHP Jelly::meta_alias怎么用?PHP Jelly::meta_alias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jelly
的用法示例。
在下文中一共展示了Jelly::meta_alias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: as_array
/**
* Return all of the rows in the result as an array.
*
* @param string column for associative keys
* @param string column for values
* @return array
*/
public function as_array($key = NULL, $value = NULL)
{
$model = Jelly::model_name($this->_model);
foreach (array('key', 'value') as $var) {
// Only alias meta-aliases
if (${$var} && FALSE !== strpos(${$var}, ':')) {
${$var} = Jelly::meta_alias($model, ${$var}, NULL);
}
}
return $this->_result->as_array($key, $value);
}
示例2: alias
/**
* Returns the actual column name for a field, field alias, or meta-alias.
*
* $field must be in the format of "model.field". Supply $value if
* you want the unique_key meta-alias to work properly.
*
* An array is returned containing the table and column keys. If the model's meta is found,
* but the field can't be found, 'column' will contain the field name passed.
*
* Returns FALSE on failure.
*
* @param string $field
* @return array
*/
public static function alias($field, $value = NULL)
{
if (FALSE !== strpos($field, '.')) {
list($model, $field) = explode('.', $field);
} else {
$model = NULL;
}
// We should at least return something now
$table = $model;
$column = $field;
// Hopefully we can find a meta object by now
$meta = Jelly::meta($model);
// Check for a meta-alias first
if (FALSE !== strpos($field, ':')) {
$field = $column = Jelly::meta_alias($meta, $field, $value);
}
if ($meta) {
$table = $meta->table();
// Alias the field
if ($field = $meta->fields($field)) {
$column = $field->column;
}
}
return array('table' => $table, 'column' => $column);
}