Esempio n. 1
0
 public function resultAction()
 {
     $this->view->setVar('siteTitle', '会员管理');
     $this->view->disable(1);
     $arr = \MagicCategory::find();
     //        $arr->toArray();
     foreach ($arr->toArray() as $key => $val) {
         echo $val['category_name'];
     }
     console($arr->toArray());
 }
 public function addAction()
 {
     if ($this->request->isAjax()) {
         $this->view->disable();
         $magicCategory = new \MagicCategory();
         $magicCategory->category_addtime = time();
         $magicCategory->category_disable = 0;
         $magicCategory->category_name = $_POST['name'];
         $magicCategory->category_sort = $_POST['sort'];
         $url = trim($_POST['url']);
         if (!empty($url)) {
             $magicCategory->category_url = $url;
         }
         $magicCategory->category_pid = $_POST['pid'];
         if ($magicCategory->save()) {
             echo json_encode(["type" => "success", "msg" => 1]);
         } else {
             foreach ($magicCategory->getMessages() as $message) {
                 echo $message->getMessage();
             }
         }
     }
 }