当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getDb方法代码示例

本文整理汇总了PHP中Application::getDb方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getDb方法的具体用法?PHP Application::getDb怎么用?PHP Application::getDb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application的用法示例。


在下文中一共展示了Application::getDb方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 public function delete()
 {
     $db = Application::getDb();
     if ($this->get('id')) {
         return $db->query("DELETE FROM {$this->tableName} WHERE id=?", array($this->get('id')));
     } else {
         return false;
     }
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:9,代码来源:Driver.php

示例2: __construct

 public function __construct($id = 0)
 {
     $db = Application::getDb();
     if (!empty($id)) {
         $res = $db->fetchRow("select * from {$this->tableName} where id=?", array($id));
     } else {
         $res = '';
     }
     if (!empty($res)) {
         $this->data = $res;
     }
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:12,代码来源:OrderConversation.php

示例3: ordersAction

 public function ordersAction()
 {
     $db = Application::getDb();
     $orders = $db->fetchAll('SELECT o.*, od.status, v.lpn, v.model, v.color, v.seats FROM orders_for_driver o LEFT JOIN vehicles v ON v.id=o.vehicle_id LEFT JOIN orders od ON od.sn=o.sn WHERE o.driver_code=? ORDER BY o.when DESC', array($this->code));
     foreach ($orders as &$order) {
         $order['via'] = json_decode($order['via']);
         $order['via_coordinates'] = json_decode($order['via_coordinates']);
     }
     unset($order);
     //$ofd = new Model_OrderForDriver();
     //$orders = $ofd->fetchPagedList(1, 999999, array('driver_code'=>$this->code), '`when` desc')['rows'];
     $this->sendResult($orders);
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:13,代码来源:PrivateCarDriverApiController.php

示例4: orderDetailAction

 public function orderDetailAction()
 {
     $db = Application::getDb();
     $order = $db->fetchRow('SELECT o.*, od.vehicle_id, od.driver_code, od.pickup_coordinates, od.dropoff_coordinates, od.via_coordinates, od.when, v.lpn, v.model, v.color, v.seats FROM orders o LEFT JOIN orders_for_driver od ON od.sn=o.sn LEFT JOIN vehicles v ON v.id=od.vehicle_id WHERE o.sn=?', array($this->sn));
     $order['via'] = json_decode($order['via']);
     $order['via_coordinates'] = json_decode($order['via_coordinates']);
     $driver = new Model_Driver($order['driver_code']);
     $order['driver_name'] = $driver->get('name');
     $order['driver_phone'] = $driver->get('phone');
     //$ofd = new Model_OrderForDriver();
     //$orders = $ofd->fetchPagedList(1, 999999, array('driver_code'=>$this->code), '`when` desc')['rows'];
     $this->sendResult($order);
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:13,代码来源:PrivateCarPassengerApiController.php

示例5: set_params

 function set_params(&$params)
 {
     parent::set_params($params);
     $db = Application::getDb();
     $user = Application::getEntityInstance('user');
     $table = $user->getTableName();
     $keyword = trim($this->getValue('search_keyword'));
     if ($keyword) {
         $skeyword = addslashes($keyword);
         $params['where'][] = "({$table}.name LIKE '%{$keyword}%' OR {$table}.email LIKE '%{$keyword}%' OR {$table}.login LIKE '%{$keyword}%')";
     }
     $role_id = $this->getValue('search_role_id');
     if ($role_id) {
         foreach ($role_id as &$r) {
             $r = (int) $r;
         }
         $coupling_table = $user->getRolesCouplingTableName();
         $role_id = implode(',', $role_id);
         $params['from'][] = "\r\n            \t\tINNER JOIN {$coupling_table} ON {$coupling_table}.user_id={$table}.id AND {$coupling_table}.role_id IN({$role_id})\r\n            \t";
         $params['group_by'][] = "{$table}.id";
     }
 }
开发者ID:alex-ch,项目名称:test,代码行数:22,代码来源:user.php

示例6: run

 public function run()
 {
     $sql_scripts = coreResourceLibrary::findAll('deploy_db_script', null, null, 'sql');
     ksort($sql_scripts);
     $db = Application::getDb();
     $show_errors_old = $db->getShowErrors();
     $db->setShowErrors(false);
     $db->execute("START TRANSACTION");
     $deploy_succeed = true;
     $executed_this_time = array();
     foreach ($sql_scripts as $script_name => $script_list) {
         if (!$deploy_succeed) {
             continue;
         }
         foreach ($script_list as $script) {
             $script_succeed = true;
             $path = $script->path;
             $sql_errors = array();
             echo "Executing {$path}... ";
             if ($this->wasExecutedBefore($path)) {
                 echo "[SKIPPED]\n";
                 continue;
             }
             $path_abs = coreResourceLibrary::getAbsolutePath($path);
             $script = file_get_contents($path_abs);
             $script = str_replace("\r\n", "\n", $script);
             $bom = pack('H*', 'EFBBBF');
             $script = preg_replace("/^{$bom}/", '', $script);
             $queries = explode(";\n", $script);
             foreach ($queries as $q) {
                 if (!$script_succeed) {
                     continue;
                 }
                 $q = trim($q);
                 if (!$q) {
                     continue;
                 }
                 $query_suceed = (bool) $db->execute($q);
                 if (!$query_suceed) {
                     $sql_errors[] = $db->getLastError();
                 }
                 $script_succeed = $script_succeed && $query_suceed;
             }
             if ($script_succeed) {
                 echo "[OK]\n";
                 $executed_this_time[] = $path;
             } else {
                 echo "[FAILED]\n";
                 echo "Errors:\n" . implode("\n", $sql_errors);
                 $deploy_succeed = false;
             }
         }
     }
     if ($deploy_succeed) {
         foreach ($executed_this_time as $ett) {
             $this->markScriptAsExecuted($ett);
         }
         $db->execute("COMMIT");
     } else {
         $db->execute("ROLLBACK");
     }
     $db->setShowErrors($show_errors_old);
 }
开发者ID:alex-ch,项目名称:test,代码行数:63,代码来源:deploy.php

示例7: isEmailExists

 public static function isEmailExists($email)
 {
     $db = Application::getDb();
     $res = $db->fetchOne("select count(*) from users where email=?", array($email));
     return $res != 0;
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:6,代码来源:User.php

示例8: connect

 /**
  * Connects to Database
  */
 protected function connect()
 {
     $adapters = Application::getDb();
     $this->slaveAdapter = $adapters['reader'];
     $this->masterAdapter = $adapters['writer'];
 }
开发者ID:cipherpols,项目名称:cze,代码行数:9,代码来源:Dataset.php

示例9: isSnExists

 public static function isSnExists($sn)
 {
     $db = Application::getDb();
     $res = $db->fetchOne("select count(*) from {$this->tableName} where sn=?", array($sn));
     return $res != 0;
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:6,代码来源:Order.php

示例10: fetchPagedList

 public function fetchPagedList($page = 1, $itemsPerPage = 0, array $where = array(), $orderBy = '', array $fields = array(), $sqlNoCache = false)
 {
     $tableName = Db::quoteIdentifier($this->tableName);
     if (empty($fields)) {
         $field = '*';
     } else {
         $cols = array();
         foreach ($fields as $name) {
             $cols[] = Db::quoteIdentifier($name);
         }
         $field = implode(',', $cols);
     }
     if (empty($where)) {
         $where = '';
     } else {
         $where = 'WHERE ' . Db::buildWhere($where);
     }
     if (!empty($orderBy)) {
         $orderBy = 'ORDER BY ' . $orderBy;
     }
     if ($itemsPerPage > 0) {
         $page = intval($page);
         $page < 1 && ($page = 1);
         $offset = ($page - 1) * $itemsPerPage;
         $limit = "LIMIT {$offset},{$itemsPerPage}";
     } else {
         $limit = '';
     }
     if ($sqlNoCache) {
         $sqlNoCache = 'SQL_NO_CACHE';
     } else {
         $sqlNoCache = '';
     }
     $countSql = "SELECT {$sqlNoCache} count(*) FROM {$tableName} {$where}";
     $sql = "SELECT {$sqlNoCache} {$field} FROM {$tableName} {$where} {$orderBy} {$limit}";
     $db = Application::getDb();
     $total = $db->fetchOne($countSql);
     $rows = $db->fetchAll($sql);
     return array('total' => $total, 'rows' => $rows);
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:40,代码来源:Base.php


注:本文中的Application::getDb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。