本文整理汇总了PHP中Restaurant::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::model方法的具体用法?PHP Restaurant::model怎么用?PHP Restaurant::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ActionViewShoppingMall
/**
* 查看购物中心
* @param $shopping_mall_id 购物中心ID
*/
public function ActionViewShoppingMall($shopping_mall_id)
{
$shopping_mall_model = ShoppingMall::model();
$shopping_mall_info = $shopping_mall_model->findByPk($shopping_mall_id);
// 获取全部品牌
$brand_criteria = new CDbCriteria();
$brand_criteria->select = array('Id', 'BrandName');
$brand = IconvEncode::ObjArrChangeArray(Brand::model()->findAll($brand_criteria), 'BrandName');
// 获取全部餐厅
$restaurant_criteria = new CDbCriteria();
$restaurant_criteria->select = array('Id', 'RestaurantName');
$restaurant = IconvEncode::ObjArrChangeArray(Restaurant::model()->findAll($restaurant_criteria), 'RestaurantName');
// 获取全部优惠卡/券
$discount_criteria = new CDbCriteria();
$discount_criteria->select = array('Id', 'DiscountCardName');
$discount_card = IconvEncode::ObjArrChangeArray(DiscountCard::model()->findAll($discount_criteria), 'DiscountCardName');
// 获取购物中心所在的的 大洲/国家/城市
$area = AreaManage::getAreaByCityid($shopping_mall_info['CityId']);
$this->renderPartial('view_shopping_mall', array('shopping_mall_info' => $shopping_mall_info, 'brand' => $brand, 'restaurant' => $restaurant, 'discount_card' => $discount_card, 'area' => $area));
}
示例2: ActionAjaxChangeRestaurantValid
/**
* 切换餐厅状态
* @return bool
*/
public function ActionAjaxChangeRestaurantValid()
{
$id = $_POST['id'];
// 获取要修改的餐厅ID
$valid = $_POST['valid'];
// 获取该餐厅当前的状态 [0:禁用 / 1:启用]
$valid = $valid == 0 ? 1 : 0;
$restaurant_model = Restaurant::model();
$restaurant_info = $restaurant_model->findByPk($id);
// 查询更改的餐厅信息
// 执行更新
if ($restaurant_info->updateByPk($id, array('Valid' => $valid)) > 0) {
// 添加操作日志 [S]
$log = Yii::app()->user->name . '于 ' . date('Y-m-d H:i:s', time()) . ' ' . ($valid == 0 ? '禁用了' : '启用了') . ' 【' . $restaurant_info['RestaurantName'] . '】 餐厅';
OperationLogManage::AddOperationLog($log);
// 添加日志
// 添加操作日志 [E]
echo true;
} else {
echo false;
}
}
示例3: actionGet_data
public function actionGet_data()
{
// var_dump($_POST);
$count = Restaurant::model()->count();
$criteria = new CDbCriteria();
if ($_POST['searchPhrase'] != '') {
$criteria->condition = 'style like ' . '"%' . $_POST['searchPhrase'] . '%" or boat like ' . '"%' . $_POST['searchPhrase'] . '%" or company like ' . '"%' . $_POST['searchPhrase'] . '%"';
}
if (isset($_POST['sort']['id'])) {
$criteria->order = " id {$_POST['sort']['id']} ";
} else {
if (isset($_POST['sort']['style'])) {
$criteria->order = "style {$_POST['sort']['style']} ";
} else {
if (isset($_POST['sort']['boat'])) {
$criteria->order = "boat {$_POST['sort']['boat']} ";
} else {
if (isset($_POST['sort']['company'])) {
$criteria->order = "company {$_POST['sort']['company']}' ";
}
}
}
}
// var_dump($criteria);
//$criteria->condition= ;
$criteria->limit = $_POST['rowCount'];
$criteria->offset = (intval($_POST['current']) - 1) * $_POST['rowCount'];
$model = Restaurant::model()->findAll($criteria);
// var_dump($model);
$arr = array();
foreach ($model as $o) {
$json = array('id' => intval($o->id), 'style' => $o->style, 'boat' => $o->boat, 'company' => $o->company);
array_push($arr, $json);
}
// var_dump( $arr);
echo json_encode(array('rowCount' => $_POST['rowCount'], 'current' => $_POST['current'], 'rows' => $arr, 'total' => $count));
}