当前位置: 首页>>代码示例>>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;未经允许,请勿转载。