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


PHP SqlQuery::execute方法代码示例

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


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

示例1: _supplierCollection

 protected function _supplierCollection($key)
 {
     $sqlQuery = new SqlQuery();
     $sql = "SELECT id, name" . $this->table . "FROM supplier`" . $this->index . "`WHERE" . $key . "\n\n                        LEFT JOIN ( SELECT id_ingredient, id_supplier, MIN(price) FROM has_supplier\n\n                            IF (id=id_supplier){min(price)}";
     $result = $sqlQuery->execute($sql);
     return $result['supplier'];
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:7,代码来源:Entity.php

示例2: load

 public function load($indexList = null, $column = false)
 {
     $sqlQuery = new SqlQuery();
     $column = $column ? $column : $this->index;
     if (isset($indexList)) {
         $indexList = " WHERE " . $column . " IN (" . implode(',', $indexList) . ")" . implode(' AND ', $this->filters);
     } else {
         $indexList = array_reduce($this->filters, function ($prev, $next) {
             return $prev == "" ? " WHERE " . $next : $prev . " AND " . $next;
         }, "");
     }
     if ($this->order) {
         $indexList .= ' ORDER BY `' . $this->orderColumn . '` ' . $this->orderDir;
     }
     if ($this->limit > -1) {
         $indexList .= ' LIMIT ' . $this->limit;
     }
     $sql = "SELECT * FROM " . $this->table . $indexList;
     $result = $sqlQuery->execute($sql);
     if ($result['status']) {
         foreach ($result['data'] as $item) {
             $this->processItem($item);
         }
     }
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:25,代码来源:Collection.php

示例3: getRelations

 public function getRelations()
 {
     $sqlQuery = new SqlQuery();
     $sql = "SELECT id FROM can_do\n                        RIGHT JOIN cocktail ON can_do.id_cocktail = cocktail.id\n                        WHERE can_do.id_barkeeper = " . $this->getId();
     $result = $sqlQuery->execute($sql);
     $result = array_map(function ($item) {
         return intval($item['id']);
     }, $result['data']);
     $cocktails = new CocktailCollection();
     $cocktails->load($result);
     return $cocktails->getItemsRaw();
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:12,代码来源:Barkeeper.php

示例4: loadByCocktail

 public function loadByCocktail($cocktailId)
 {
     $sqlQuery = new SqlQuery();
     $sql = "SELECT id_ingredient as id FROM has_ingredient WHERE id_cocktail=" . $cocktailId;
     $result = $sqlQuery->execute($sql);
     if ($result['status']) {
         $ingredientList = array_map(function ($item) {
             return $item['id'];
         }, $result['data']);
         $this->load($ingredientList);
     }
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:12,代码来源:IngredientCollection.php

示例5: loadByQuery

 public function loadByQuery($query, $alc, $cal, $exclusions)
 {
     $sqlQuery = new SqlQuery();
     $cocktails = null;
     $sql = "SELECT id, `name` FROM cocktail\n\n                        LEFT JOIN (\n\n                            SELECT has_ingredient.id_cocktail, ROUND((SUM(ingredients.alcohol) / COUNT(ingredients.alcohol)), 2) as alcohol, SUM(ingredients.calories) as calories FROM has_ingredient\n\n                                LEFT JOIN (\n\n                                    SELECT has_alternative.id_origin, ingredient.id, ingredient.alcohol, ingredient.calories FROM has_alternative\n\n                                        RIGHT JOIN ingredient\n\n                                        ON has_alternative.id_target = ingredient.id\n\n                                        WHERE ingredient.id NOT IN (" . $exclusions . ")\n\n                                ) AS ingredients\n\n                                ON ingredients.id_origin = has_ingredient.id_ingredient OR ingredients.id = has_ingredient.id_ingredient\n                                GROUP BY id_cocktail\n                                HAVING COUNT(ingredients.id) = COUNT(id_cocktail)\n\n                        ) as cocktails\n\n                    ON cocktail.id = id_cocktail\n                    WHERE cocktails.alcohol <= " . $alc . " AND cocktails.calories <= " . $cal . " AND cocktail.name LIKE '" . $query . "%'";
     $result = $sqlQuery->execute($sql);
     if ($result['status']) {
         $cocktails = array_map(function ($item) {
             return $item['id'];
         }, $result['data']);
         $this->orderBy('ranking', 'ASC');
         $this->load($cocktails);
     }
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:14,代码来源:CocktailCollection.php

示例6: update

 static function update($db, $table_name, $data, $where, $bindings = null)
 {
     $query = new SqlQuery($db, $table_name, 'update');
     $query->where = $where;
     $query->bindings = $bindings;
     $query->data = $data;
     return $query->execute();
 }
开发者ID:lotcz,项目名称:zshop,代码行数:8,代码来源:query.php

示例7: getRelations

 public function getRelations()
 {
     $sqlQuery = new SqlQuery();
     $sql = "SELECT id, name, price FROM has_supplier\n                        RIGHT JOIN supplier ON has_supplier.id_supplier = supplier.id\n                        WHERE has_supplier.id_ingredient = " . $this->getId();
     $result = $sqlQuery->execute($sql);
     return $result['data'];
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:7,代码来源:Ingredient.php

示例8: isFlopTen

 public function isFlopTen()
 {
     $sqlQuery = new SqlQuery();
     $sql = 'SELECT id FROM (SELECT id, ranking FROM cocktail ORDER BY ranking ASC LIMIT 10) AS j1 WHERE id = ' . $this->getId();
     $result = $sqlQuery->execute($sql);
     return count($result['data']) > 0;
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:7,代码来源:Cocktail.php

示例9: removeIngredientSupplierRelation

 public static function removeIngredientSupplierRelation($session)
 {
     $sqlQuery = new SqlQuery();
     $list = json_decode($session['entity']);
     $positive = 0;
     foreach ($list as $item) {
         $sql = "SELECT id_supplier FROM has_supplier WHERE id_supplier = " . $item . " AND id_ingredient = " . $session['entityID'] . " LIMIT 1";
         $doesExist = $sqlQuery->execute($sql);
         $doesExist = count($doesExist['data']);
         if ($doesExist) {
             $sql = "DELETE FROM has_supplier WHERE id_ingredient = " . $session['entityID'] . " AND id_supplier = " . $item;
             $result = $sqlQuery->execute($sql);
             $positive += $result['status'];
         }
     }
     return $positive == count($list);
 }
开发者ID:TitanNano,项目名称:DatenbankenProjekt,代码行数:17,代码来源:ActionsMap.php


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