當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Service::getDB方法代碼示例

本文整理匯總了PHP中Service::getDB方法的典型用法代碼示例。如果您正苦於以下問題:PHP Service::getDB方法的具體用法?PHP Service::getDB怎麽用?PHP Service::getDB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Service的用法示例。


在下文中一共展示了Service::getDB方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 /**
  * Saves a token
  * 
  * @return mixed (boolean/integer) false if failed
  */
 public function save()
 {
     $this->token = $this->generateToken();
     $this->date = $this->now();
     $dataToSave = array();
     $q = "select `id` from `" . $this->table . "` where `app`='" . $this->app . "'  LIMIT 1";
     $rows = Service::getDB()->query($q);
     foreach ($this->attributes as $attr) {
         $k = $attr[0];
         $dataToSave[$k] = $this->{$k};
     }
     if (sizeof($rows) > 0) {
         Service::getDB()->where('id', $rows[0]['id']);
         $insertId = Service::getDB()->update($this->table, $dataToSave);
     } else {
         $insertId = Service::getDB()->insert($this->table, $dataToSave);
     }
     if ($this->id == "") {
         $this->id = $insertId;
     }
     return $this->token;
 }
開發者ID:AugustoAngeletti,項目名稱:erepublik,代碼行數:27,代碼來源:AuthToken.php

示例2: addStock

 /**
  * Adds stock items to the company
  * @param integer $quantity amount of stock to be added
  * @param integer $type can be RESOURCE or PRODUCT
  * 
  * @return boolean if added
  */
 public function addStock($quantity, $type)
 {
     $db = Service::getDB();
     $where = array('company' => $this->id, 'product' => $this->product, 'productType' => $type);
     if ($type == Company::PRODUCT_TYPE_PRODUCT) {
         $condition = "AND quality='" . $this->quality . "' ";
         $where['quality'] = $this->quality;
     } else {
         $condition = "";
         $where['quality'] = 0;
     }
     $r = $db->query("SELECT quantity FROM company_stock WHERE company='" . $this->id . "' AND product='" . $this->product . "' AND productType='" . $type . "' " . $condition);
     if (sizeof($r) == 0) {
         $stock = $quantity;
         $where['quantity'] = $stock;
         return $db > insert('company_stock', $where);
     } else {
         $stock = $r[0]['quantity'] + $quantity;
         $data = array('quantity' => $stock);
         $db->where($where);
         return $db->update('company_stock', $data);
     }
 }
開發者ID:AugustoAngeletti,項目名稱:erepublik,代碼行數:30,代碼來源:Company.php

示例3: saveNew

 /**
  * creates a new user
  * 
  * @return mixed (uid or false)
  */
 public function saveNew()
 {
     $this->status = self::STATUS_PENDING;
     $this->gold = 0;
     $this->xp = 0;
     $this->language = 'en';
     $q = "select `id` from `" . $this->table . "` where `email`='" . $this->email . "' OR `nick`='" . $this->nick . "' LIMIT 1";
     $rows = Service::getDB()->query($q);
     if (sizeof($rows) > 0) {
         return false;
     }
     return parent::saveNew();
 }
開發者ID:AugustoAngeletti,項目名稱:erepublik,代碼行數:18,代碼來源:User.php

示例4: delete

 /**
  * Deletes the object from the database
  * @return boolean
  */
 function delete()
 {
     Service::getDB()->where('id', $this->id);
     return Service::getDB()->delete($this->table, 1);
 }
開發者ID:AugustoAngeletti,項目名稱:erepublik,代碼行數:9,代碼來源:BasicClass.php


注:本文中的Service::getDB方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。