本文整理汇总了PHP中UserQuery::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserQuery::save方法的具体用法?PHP UserQuery::save怎么用?PHP UserQuery::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserQuery
的用法示例。
在下文中一共展示了UserQuery::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editUserQuery
/**
* edit user query
*
* @author youzhao.zxw<swustnjtu@gmail.com>
* @param string $title user query title
* @param int $productId product id
* @param string $type bug,case or result
* @param array $searchConditionArr search condition array
* @return array edit user query result information
*/
public static function editUserQuery($title, $productId, $type, $searchConditionArr)
{
$resultInfo = array();
$updateFlag = false;
$title = trim($title);
$userQuery = UserQuery::model()->findByAttributes(array('query_type' => $type, 'product_id' => $productId, 'created_by' => Yii::app()->user->id, 'title' => $title));
if (false != $userQuery) {
$updateFlag = true;
$userQuery->updated_at = date(CommonService::DATE_FORMAT);
} else {
$userQuery = new UserQuery();
$userQuery->created_by = Yii::app()->user->id;
$userQuery->created_at = date(CommonService::DATE_FORMAT);
$userQuery->updated_at = $userQuery->created_at;
$userQuery->query_type = $type;
$userQuery->product_id = $productId;
$userQuery->title = $title;
}
$searchRowConditionArr = SearchService::getSearchConditionArr($searchConditionArr);
$queryConditonArr = array();
$keyArr = array('leftParenthesesName', 'field', 'operator', 'value', 'rightParenthesesName', 'andor');
foreach ($searchRowConditionArr as $rowCondtion) {
foreach ($rowCondtion as $key => $value) {
$queryConditonArr[$key][] = $value;
}
}
$userQuery->left_parentheses = serialize($queryConditonArr['leftParenthesesName']);
$userQuery->fieldlist = serialize($queryConditonArr['field']);
$userQuery->operatorlist = serialize($queryConditonArr['operator']);
$userQuery->valuelist = serialize($queryConditonArr['value']);
$userQuery->right_parentheses = serialize($queryConditonArr['rightParenthesesName']);
$userQuery->andorlist = serialize($queryConditonArr['andor']);
if ($userQuery->save()) {
$resultInfo['status'] = CommonService::$ApiResult['SUCCESS'];
if ($updateFlag) {
$resultInfo['detail'] = array('id' => Yii::t('Common', self::TIP_UPDATE_SUCCESS));
} else {
$resultInfo['detail'] = array('id' => Yii::t('Common', self::TIP_CREATE_SUCCESS));
}
} else {
$resultInfo['status'] = CommonService::$ApiResult['FAIL'];
$resultInfo['detail'] = $userQuery->getErrors();
}
return $resultInfo;
}