本文整理汇总了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'];
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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'];
}
示例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;
}
示例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);
}