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


PHP ZurmoRedBean::findOne方法代码示例

本文整理汇总了PHP中ZurmoRedBean::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP ZurmoRedBean::findOne方法的具体用法?PHP ZurmoRedBean::findOne怎么用?PHP ZurmoRedBean::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZurmoRedBean的用法示例。


在下文中一共展示了ZurmoRedBean::findOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getByName

 /**
  * Given a name, get the custom field data model.  Attempts to retrieve from cache, if it is not available,
  * will attempt to retrieve from persistent storage, cache the model, and return.
  * @param string $name
  * @return CustomFieldData model
  * @throws NotFoundException
  */
 public static function getByName($name, $shouldCache = true)
 {
     if (isset(self::$cachedModelsByName[$name])) {
         return self::$cachedModelsByName[$name];
     }
     try {
         // not using default value to save cpu cycles on requests that follow the first exception.
         return GeneralCache::getEntry('CustomFieldData' . $name);
     } catch (NotFoundException $e) {
         assert('is_string($name)');
         assert('$name != ""');
         $bean = ZurmoRedBean::findOne('customfielddata', "name = :name ", array(':name' => $name));
         assert('$bean === false || $bean instanceof RedBean_OODBBean');
         if ($bean === false) {
             $customFieldData = new CustomFieldData();
             $customFieldData->name = $name;
             $customFieldData->serializedData = serialize(array());
             // An unused custom field data does not present as needing saving.
             $customFieldData->setNotModified();
         } else {
             $customFieldData = self::makeModel($bean);
         }
         if ($shouldCache) {
             self::$cachedModelsByName[$name] = $customFieldData;
             GeneralCache::cacheEntry('CustomFieldData' . $name, $customFieldData);
         }
         return $customFieldData;
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:36,代码来源:CustomFieldData.php

示例2: getByName

 public static function getByName($name)
 {
     assert('is_string($name)');
     assert('$name != ""');
     $bean = ZurmoRedBean::findOne('a', "name = :name ", array(':name' => $name));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     }
     return self::makeModel($bean);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:11,代码来源:MixedRelationsModel.php

示例3: getByClassName

 /**
  * Get by specifying a class name. The class name is unique
  * and so one object will be returned.
  */
 public static function getByClassName($className)
 {
     assert('is_string($className)');
     assert('$className != ""');
     $bean = ZurmoRedBean::findOne('globalmetadata', "className = '{$className}'");
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     }
     return self::makeModel($bean);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:15,代码来源:GlobalMetadata.php

示例4: getByClassNameAndUser

 /**
  * Get by specifying a class name and user. The class name is unique
  * and the data is saved in such a way that only one record will be
  * created per class name / user combination.
  * @see GlobalMetadata
  */
 public static function getByClassNameAndUser($className, User $user)
 {
     assert('is_string($className)');
     assert('$className != ""');
     $bean = ZurmoRedBean::findOne('perusermetadata', "className = '{$className}' and _user_id = {$user->id}");
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     }
     return self::makeModel($bean);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:17,代码来源:PerUserMetadata.php

示例5: getByUsername

 /**
  * @param string $username
  * @throws NotFoundException
  */
 public static function getByUsername($username)
 {
     assert('is_string($username)');
     assert('$username != ""');
     $bean = ZurmoRedBean::findOne('_user', "username = :username ", array(':username' => $username));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     }
     RedBeansCache::cacheBean($bean, static::getTableName() . $bean->id);
     return self::makeModel($bean);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:16,代码来源:User.php

示例6: getByModuleNameAndPolicyName

 /**
  * @param string $moduleName
  * @param string $policyName
  * @return An
  * @throws NotFoundException
  */
 public static function getByModuleNameAndPolicyName($moduleName, $policyName)
 {
     assert('is_string($moduleName)');
     assert('is_string($policyName)');
     assert('$moduleName != ""');
     assert('$policyName != ""');
     $bean = ZurmoRedBean::findOne('policy', "modulename = '{$moduleName}' and name = '{$policyName}'");
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     }
     return self::makeModel($bean);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:19,代码来源:Policy.php

示例7: getByName

 public static function getByName($name)
 {
     assert('is_string($name)');
     assert('$name != ""');
     $bean = ZurmoRedBean::findOne('testselfrelatingmodel', "name = :name ", array(':name' => $name));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         if ($name == Group::EVERYONE_GROUP_NAME) {
             return self::createEveryoneGroup();
         }
         throw new NotFoundException();
     }
     return self::makeModel($bean);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:14,代码来源:TestSelfRelatingModel.php

示例8: getByName

 public static function getByName($name)
 {
     assert('is_string($name)');
     assert('$name != ""');
     $bean = ZurmoRedBean::findOne(EmailBox::getTableName(), "name = :name ", array(':name' => $name));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     } else {
         $box = self::makeModel($bean);
     }
     $box->setSpecialBox();
     return $box;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:14,代码来源:EmailBox.php

示例9: getByCode

 public static function getByCode($languageCode, $modelClassName = null)
 {
     assert('!empty($languageCode)');
     assert('$modelClassName === null || is_string($modelClassName) && $modelClassName != ""');
     if ($modelClassName === null) {
         $modelClassName = get_called_class();
     }
     $tableName = $modelClassName::getTableName();
     $bean = ZurmoRedBean::findOne($tableName, ' code = :code', array(':code' => $languageCode));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if (!is_object($bean)) {
         throw new NotFoundException();
     }
     return self::makeModel($bean, $modelClassName);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:15,代码来源:ActiveLanguage.php

示例10: getBySourceIdAndLangCode

 /**
  * Gets a model from the database by source message id and langcode
  * @param $sourceId Integer Id of the source message
  * @param $languageCode String Language code of the translation
  * @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 getBySourceIdAndLangCode($sourceId, $languageCode, $modelClassName = null)
 {
     assert('intval($sourceId) && $sourceId > 0');
     assert('!empty($languageCode)');
     assert('$modelClassName === null || is_string($modelClassName) && $modelClassName != ""');
     if ($modelClassName === null) {
         $modelClassName = get_called_class();
     }
     $tableName = $modelClassName::getTableName();
     $bean = ZurmoRedBean::findOne($tableName, ' messagesource_id = :sourceId AND language = :languageCode', array(':sourceId' => $sourceId, ':languageCode' => $languageCode));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if (!is_object($bean)) {
         throw new NotFoundException();
     }
     return self::makeModel($bean, $modelClassName);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:24,代码来源:MessageTranslation.php

示例11: getByUserAndName

 /**
  * @param User $user
  * @param mixed $name null or String representing the email account name
  */
 public static function getByUserAndName(User $user, $name = null)
 {
     if ($name == null) {
         $name = self::DEFAULT_NAME;
     } else {
         //For now Zurmo does not support multiple email accounts
         throw new NotSupportedException();
     }
     assert('is_string($name)');
     $bean = ZurmoRedBean::findOne(SendGridEmailAccount::getTableName(), "_user_id = ? AND name = ?", array($user->id, $name));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     } else {
         $emailAccount = self::makeModel($bean);
     }
     return $emailAccount;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:22,代码来源:SendGridEmailAccount.php

示例12: getByName

 /**
  * @param string $name
  * @return An|Group
  * @throws NotFoundException
  */
 public static function getByName($name)
 {
     assert('is_string($name)');
     assert('$name != ""');
     $bean = ZurmoRedBean::findOne('_group', "name = :name ", array(':name' => $name));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         if ($name != self::EVERYONE_GROUP_NAME && $name != self::SUPER_ADMINISTRATORS_GROUP_NAME) {
             throw new NotFoundException();
         }
         $group = new Group();
         $group->unrestrictedSet('name', $name);
     } else {
         $group = self::makeModel($bean);
     }
     $group->setSpecialGroup();
     return $group;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:23,代码来源:Group.php

示例13: getByName

 /**
  * Given a name, check the cache if the model is cached and return. Otherwise check the database for the record,
  * cache and return this model.
  * @param string $name
  */
 public static function getByName($name)
 {
     assert('is_string($name)');
     assert('$name != ""');
     try {
         // not using default value to save cpu cycles on requests that follow the first exception.
         return GeneralCache::getEntry('NamedSecurableItem' . $name);
     } catch (NotFoundException $e) {
         $bean = ZurmoRedBean::findOne('namedsecurableitem', "name = :name ", array(':name' => $name));
         assert('$bean === false || $bean instanceof RedBean_OODBBean');
         if ($bean === false) {
             $model = new NamedSecurableItem();
             $model->unrestrictedSet('name', $name);
         } else {
             $model = self::makeModel($bean);
         }
     }
     GeneralCache::cacheEntry('NamedSecurableItem' . $name, $model);
     return $model;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:25,代码来源:NamedSecurableItem.php

示例14: getByE

 public static function getByE($e)
 {
     assert('is_string($e)');
     assert('$e != ""');
     $bean = ZurmoRedBean::findOne('e', "e = '{$e}'");
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         // we need this because C uses dynamic default values from it and we need this table to be available.
         RedBeanModelsToTablesAdapter::generateTablesFromModelClassNames(array('E'), new MessageLogger());
         $model = new E();
         $model->e = $e;
         $saved = $model->save();
         if (!$saved) {
             throw new FailedToSaveModelException();
         }
         return $model;
     } else {
         $model = static::makeModel($bean);
     }
     return $model;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:21,代码来源:E.php

示例15: getUrlByHash

 /**
  * Given an hash return the stored url or throws exception if hash does not exists
  * @param string $hash
  * @return string
  * @throws NotFoundException
  */
 public static function getUrlByHash($hash)
 {
     assert('is_string($hash)');
     assert('$hash != ""');
     $className = __CLASS__;
     $bean = ZurmoRedBean::findOne($className::getTableName(), "hash = :hash ", array(':hash' => $hash));
     assert('$bean === false || $bean instanceof RedBean_OODBBean');
     if ($bean === false) {
         throw new NotFoundException();
     } else {
         $shortUrl = self::makeModel($bean);
     }
     return $shortUrl->url;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:ShortUrl.php


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