Example #1
0
 public function additemtodbAction()
 {
     $name = $this->getRequest()->getParam('name');
     $description = $this->getRequest()->getParam('description');
     $vote_count = $this->getRequest()->getParam('vote_count');
     $data = array('name' => $name, 'description' => $description, 'vote_count' => $vote_count);
     $itemModel = new Item();
     $itemModel->insert($data);
     $this->render('ok');
 }
Example #2
0
 /**
  * @param : array $data
  * @return int $id
  */
 public static function insert($data)
 {
     if (!is_array($data) || !count($data)) {
         return;
     }
     $shipFromData = $data['shipFrom'];
     $shipToData = $data['shipTo'];
     $itemData = $data['item'];
     $companyData = $data['company'];
     $shipFromId = ShipFrom::insert($shipFromData);
     $shipToId = ShipTo::insert($shipToData);
     $itemId = Item::insert($itemData);
     $companyId = Company::insert($companyData);
     $orderData = array('reference_no' => 'SPR-' . rand(), 'created_on' => date('Y-m-d'), 'user_id' => User::getUserId(), 'ship_to' => $shipToId, 'ship_from' => $shipFromId, 'item_id' => $itemId, 'company_id' => $companyId);
     $id = DB::table('order')->insertGetId($orderData);
     return $id;
 }
 public function testScope()
 {
     Item::insert(array(array('name' => 'knife', 'type' => 'sharp'), array('name' => 'spoon', 'type' => 'round')));
     $sharp = Item::sharp()->get();
     $this->assertEquals(1, $sharp->count());
 }
 public function actionAddMoreItem()
 {
     if (isset($_REQUEST["category_item"]) && $_REQUEST["category_item"] != "") {
         $item = new Item();
         $item->isMandatory = false;
         $item->name = $_REQUEST["item-name"];
         $item->category = $_REQUEST["category_item"];
         $item->main_category = $_REQUEST["main_category_item"];
         $item->insert();
         echo $item->id;
     }
 }