本文整理汇总了PHP中RedBeanModel::makeModel方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModel::makeModel方法的具体用法?PHP RedBeanModel::makeModel怎么用?PHP RedBeanModel::makeModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModel
的用法示例。
在下文中一共展示了RedBeanModel::makeModel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModelByExternalSystemIdAndModelClassName
/**
* Given an external system id and model class name, try to find the associated model if it exists. If it is
* not found, a NotFoundException will be thrown. Otherwise the model will be made and returned.
* @param string $id
* @param string $modelClassName
* @return RedBeanModel $model
* @throws NotFoundException
*/
public static function getModelByExternalSystemIdAndModelClassName($id, $modelClassName)
{
assert('$id != null && is_string($id)');
assert('is_string($modelClassName)');
$tableName = $modelClassName::getTableName();
$beans = ZurmoRedBean::find($tableName, ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME . " = '{$id}'");
assert('count($beans) <= 1');
if (count($beans) == 0) {
throw new NotFoundException();
}
return RedBeanModel::makeModel(end($beans), $modelClassName);
}
示例2: getById
/**
* Gets a model from the database by Id.
* @param $id Integer Id.
* @param $modelClassName Pass only when getting it at runtime
* gets the wrong name.
* @return A model of the type of the extending model.
*/
public static function getById($id, $modelClassName = null)
{
assert('is_integer($id) && $id > 0');
assert('$modelClassName === null || is_string($modelClassName) && $modelClassName != ""');
// I would have thought it was correct to user R::load() and get
// a null, or error or something if the bean doesn't exist, but
// it still returns a bean. So until I've investigated further
// I'm using Finder.
if ($modelClassName === null) {
$modelClassName = get_called_class();
}
$tableName = self::getTableName($modelClassName);
$beans = R::find($tableName, "id = '{$id}'");
assert('count($beans) <= 1');
if (count($beans) == 0) {
throw new NotFoundException();
}
return RedBeanModel::makeModel(end($beans), $modelClassName);
}
示例3: getByHashIndex
/**
* @param string $hashIndex row identifier for ContactWebFormEntry
* @return array of module class names and display labels.
*/
public static function getByHashIndex($hashIndex)
{
$modelClassName = get_called_class();
$tableName = self::getTableName($modelClassName);
$columnName = self::getColumnNameByAttribute('hashIndex');
$beans = R::find($tableName, "{$columnName} = '{$hashIndex}'");
assert('count($beans) <= 1');
if (count($beans) == 0) {
return null;
} else {
return RedBeanModel::makeModel(end($beans), $modelClassName);
}
}
示例4: getByCode
/**
* Gets a currency by code.
* @param $code String Code.
* @return A model of type currency
*/
public static function getByCode($code)
{
assert('is_string($code)');
$tableName = self::getTableName('Currency');
$beans = R::find($tableName, "code = '{$code}'");
assert('count($beans) <= 1');
if (count($beans) == 0) {
throw new NotFoundException();
}
return RedBeanModel::makeModel(end($beans), 'Currency');
}
示例5: getByIndex
/**
* Returns a model by index. Used by Iterator.
* @param $i An integer index >= 0 and < count().
*/
protected function getByIndex($i)
{
assert('is_int($i)');
assert('$i >= 0');
assert('$i < $this->count()');
$beanOrModel = $this->relatedBeansAndModels[$i];
if ($beanOrModel instanceof RedBean_OODBBean) {
$model = RedBeanModel::makeModel($beanOrModel, $this->modelClassName);
$this->relatedBeansAndModels[$i] = $model;
}
return $this->relatedBeansAndModels[$i];
}