当前位置: 首页>>代码示例>>PHP>>正文


PHP RedBeanModel::makeModel方法代码示例

本文整理汇总了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);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:ExternalSystemIdSuppportedSanitizerUtil.php

示例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);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:26,代码来源:RedBeanModel.php

示例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);
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:17,代码来源:ContactWebFormEntry.php

示例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');
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:16,代码来源:Currency.php

示例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];
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:16,代码来源:RedBeanModels.php


注:本文中的RedBeanModel::makeModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。