本文整理汇总了PHP中ZurmoRedBean::find方法的典型用法代码示例。如果您正苦于以下问题:PHP ZurmoRedBean::find方法的具体用法?PHP ZurmoRedBean::find怎么用?PHP ZurmoRedBean::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZurmoRedBean
的用法示例。
在下文中一共展示了ZurmoRedBean::find方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSinceDateTime
public static function getSinceDateTime($dateTime)
{
assert('DateTimeUtil::isValidDbFormattedDateTime($dateTime)');
return self::makeModels($beans = ZurmoRedBean::find('auditevent', "datetime >= '{$dateTime}'"));
}
示例3: getByModuleName
/**
* Gets all of the configuration entries for a module.
* @param $user id
* @return An array of arrays, keyed first on the module names, and
* then the entry keys.
*/
public static function getByModuleName($userId, $moduleName)
{
assert('$userId != null && is_int($userId)');
assert('$moduleName != ""');
$beans = ZurmoRedBean::find(UserConfiguration::getTableName(), "userId = {$userId} and moduleName = '{$moduleName}'");
$moduleEntries = array();
foreach ($beans as $bean) {
if (!isset($moduleEntries[$bean->moduleName])) {
$moduleEntries[$bean->moduleName] = array();
}
$moduleEntries[$bean->moduleName][$bean->key] = $bean->value;
}
return $moduleEntries;
}
示例4: constructRelatedBeansAndModels
/**
* Handles constructing the relatedBeansAndModels with special attention to the case where it is PolyOneToMany
* @param string $modelClassName
* @param mixed $sqlOrBean
*/
private function constructRelatedBeansAndModels($modelClassName, $sqlOrBean = '')
{
assert('is_string($sqlOrBean) || $sqlOrBean instanceof RedBean_OODBBean');
$tableName = $modelClassName::getTableName();
if (is_string($sqlOrBean)) {
$this->relatedBeansAndModels = array_values($beans = ZurmoRedBean::find($tableName, $sqlOrBean));
} else {
assert('$sqlOrBean instanceof RedBean_OODBBean');
$this->bean = $sqlOrBean;
try {
if ($this->bean->id > 0) {
if ($this->linkType == RedBeanModel::LINK_TYPE_POLYMORPHIC) {
$value = array();
$values['id'] = $this->bean->id;
$values['type'] = $this->bean->getMeta('type');
$this->relatedBeansAndModels = array_values(ZurmoRedBean::find($tableName, strtolower($this->linkName) . '_id = :id AND ' . strtolower($this->linkName) . '_type = :type', $values));
} else {
$relatedIds = ZurmoRedBeanLinkManager::getKeys($this->bean, $tableName, $this->resolveLinkNameForCasing());
$this->relatedBeansAndModels = array_values(ZurmoRedBean::batch($tableName, $relatedIds));
}
} else {
$this->relatedBeansAndModels = array();
}
} catch (RedBean_Exception_SQL $e) {
// SQLSTATE[42S02]: Base table or view not found...
// SQLSTATE[42S22]: Column not found...
if (!in_array($e->getSQLState(), array('42S02', '42S22'))) {
throw $e;
}
$this->relatedBeansAndModels = array();
}
}
}
示例5: 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 = $modelClassName::getTableName();
$columnName = self::getColumnNameByAttribute('hashIndex');
$beans = ZurmoRedBean::find($tableName, "{$columnName} = '{$hashIndex}'");
assert('count($beans) <= 1');
if (count($beans) == 0) {
return null;
} else {
return static::makeModel(end($beans), $modelClassName);
}
}
示例6: getDeptRefById
public static function getDeptRefById($id)
{
return self::makeModels(ZurmoRedBean::find('departmentreference', "id =:id", array(':id' => $id)));
}
示例7: getByRelatedClassId
protected static function getByRelatedClassId($relatedModelClassName, $id, $modelClassName = null)
{
assert('is_string($relatedModelClassName)');
assert('$relatedModelClassName != ""');
assert('is_int($id)');
//assert('$id > 0');
assert('$modelClassName === null || is_string($modelClassName) && $modelClassName != ""');
if ($modelClassName === null) {
$modelClassName = get_called_class();
}
$tableName = $relatedModelClassName::getTableName();
$foreignKeyName = strtolower($modelClassName) . '_id';
$beans = ZurmoRedBean::find($tableName, "{$foreignKeyName} = {$id}");
return self::makeModels($beans, $relatedModelClassName);
}
示例8: getByName
public static function getByName($name)
{
assert('is_string($name) && $name != ""');
return self::makeModels(ZurmoRedBean::find('contactstate', "name = :name ", array(':name' => $name)));
}
示例9: getUnitofmeasureByNameEdit
public static function getUnitofmeasureByNameEdit($name, $id)
{
return self::makeModels(ZurmoRedBean::find('unitofmeasure', "name = :name AND id != :id", array(':name' => $name, ':id' => $id)));
}
示例10: isLanguageADefaultLanguageForAnyUsers
/**
* Given a language, is it in use as a default language by any of the users.
* @param string $language
* @return true if in use, otherwise returns false.
*/
protected function isLanguageADefaultLanguageForAnyUsers($language)
{
assert('is_string($language)');
$tableName = User::getTableName();
$beans = ZurmoRedBean::find($tableName, "language = '{$language}'");
if (count($beans) > 0) {
return true;
}
return false;
}
示例11: 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 = Currency::getTableName();
$beans = ZurmoRedBean::find($tableName, "code = '{$code}'");
assert('count($beans) <= 1');
if (count($beans) == 0) {
throw new NotFoundException();
}
return static::makeModel(end($beans), 'Currency');
}
示例12: getCategoryByNameEdit
public static function getCategoryByNameEdit($name, $id)
{
return self::makeModels(ZurmoRedBean::find('category', "name = :name AND id != :id", array(':name' => $name, ':id' => $id)));
}
示例13: getProductCode
/**
* Returns the display name for the model class.
* @return dynamic label name based on module.
*/
public static function getProductCode($productCode)
{
return self::makeModels(ZurmoRedBean::find('costbook', "productcode = :productcode ", array(':productcode' => $productCode)));
}