本文整理匯總了PHP中UserQuery::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserQuery::model方法的具體用法?PHP UserQuery::model怎麽用?PHP UserQuery::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserQuery
的用法示例。
在下文中一共展示了UserQuery::model方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getQueryConditionById
public static function getQueryConditionById($queryId)
{
$resultInfo = array();
$queryInfo = UserQuery::model()->findByPk($queryId);
if ($queryInfo == null) {
$resultInfo['status'] = CommonService::$ApiResult['FAIL'];
$resultInfo['detail']['id'] = 'query not existed';
return $resultInfo;
} else {
$userAccessableProductIdArr = Yii::app()->user->getState('visit_product_id');
if (!in_array($queryInfo['product_id'], $userAccessableProductIdArr)) {
$resultInfo['status'] = CommonService::$ApiResult['FAIL'];
$resultInfo['detail']['id'] = 'has not visit right';
return $resultInfo;
}
}
$parsedQueryInfo = array();
$parsedQueryInfo['product_id'] = $queryInfo['product_id'];
$parsedQueryInfo['query_type'] = $queryInfo['query_type'];
$parsedQueryInfo['title'] = $queryInfo['title'];
$searchArr['leftParenthesesName'] = unserialize($queryInfo->left_parentheses);
$searchArr['field'] = unserialize($queryInfo->fieldlist);
$searchArr['operator'] = unserialize($queryInfo->operatorlist);
$searchArr['value'] = unserialize($queryInfo->valuelist);
$searchArr['rightParenthesesName'] = unserialize($queryInfo->right_parentheses);
$searchArr['andor'] = unserialize($queryInfo->andorlist);
$returnArr = array();
$fieldCount = count($searchArr['field']);
$keyArr = array('leftParenthesesName', 'field', 'operator', 'value', 'rightParenthesesName', 'andor');
for ($i = 0; $i < $fieldCount; $i++) {
$rowArr = array();
foreach ($keyArr as $key) {
$rowArr[$key] = $searchArr[$key][$i];
}
$returnArr[] = $rowArr;
}
$parsedQueryInfo['search_condition'] = $returnArr;
$resultInfo['status'] = CommonService::$ApiResult['SUCCESS'];
$resultInfo['detail'] = $parsedQueryInfo;
return $resultInfo;
}
示例2: actionDeleteTemplateOrQuery
public function actionDeleteTemplateOrQuery()
{
$id = $_GET['id'];
$type = $_GET['type'];
if ('template' == $type) {
$tmpInfo = UserTemplate::model()->findByAttributes(array('id' => $id, 'created_by' => Yii::app()->user->id));
} elseif ('query' == $type) {
$tmpInfo = UserQuery::model()->findByAttributes(array('id' => $id, 'created_by' => Yii::app()->user->id));
}
if ($tmpInfo !== null) {
$tmpInfo->delete();
}
echo CommonService::$ApiResult['SUCCESS'];
}