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


PHP SqlQuery::executeSQL方法代码示例

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


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

示例1: loadCartTotals

 static function loadCartTotals($db, $customer_id)
 {
     $totals = [];
     $sql = 'SELECT SUM(product_price * cart_count) AS p FROM viewProductsInCart WHERE cart_customer_id = ?';
     $statement = SqlQuery::executeSQL($db, $sql, [$customer_id]);
     $result = $statement->get_result();
     if ($row = $result->fetch_assoc()) {
         $totals = $row;
         $selected_currency = Currency::getSelectedCurrency($db);
         $totals['pf'] = formatPrice($row['p'], $selected_currency);
         $totals['pc'] = $row['p'] / $selected_currency->fval('currency_value');
     }
     $statement->close();
     return $totals;
 }
开发者ID:lotcz,项目名称:zshop,代码行数:15,代码来源:cart.m.php

示例2: execute

 public function execute()
 {
     if (isset($this->orderby)) {
         $this->orderbySQL = sprintf('ORDER BY %s', $this->orderby);
     }
     if (isset($this->paging)) {
         $this->limitSQL = sprintf('LIMIT %d,%d', $this->paging->offset, $this->paging->limit);
     }
     if (isset($this->where)) {
         $this->whereSQL = sprintf('WHERE %s', $this->where);
     }
     if (isset($this->data)) {
         $columns = [];
         $bindings = [];
         foreach ($this->data as $key => $value) {
             $columns[] = SqlQuery::validateColumn($key) . ' = ?';
             $bindings[] =& $value;
         }
         // prepend bindings because SET comes before WHERE
         $this->bindings = array_merge($bindings, $this->bindings);
         $this->setSQL = sprintf('SET %s', implode(',', $columns));
     }
     switch ($this->query_type) {
         case 'update':
             $sql = sprintf('UPDATE %s %s %s', $this->table_name, $this->setSQL, $this->whereSQL);
             break;
         case 'select':
         default:
             $sql = sprintf('SELECT * FROM %s %s %s %s', $this->table_name, $this->whereSQL, $this->orderbySQL, $this->limitSQL);
     }
     if (isset($this->paging) && !isset($this->paging->total_records)) {
         $this->paging->total_records = SqlQuery::getRecordCount($this->db, $this->table_name, $this->whereSQL, $this->bindings, $this->types);
     }
     //dbg($sql);
     //var_dump($this->bindings);
     return SqlQuery::executeSQL($this->db, $sql, $this->bindings, $this->types);
 }
开发者ID:lotcz,项目名称:zshop,代码行数:37,代码来源:query.php


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