Skip to content

Latest commit

 

History

History
331 lines (168 loc) · 6.35 KB

class.DbQueryCore.md

File metadata and controls

331 lines (168 loc) · 6.35 KB

Class DbQueryCore

SQL query builder

Contents

Properties

Methods

Properties

$query

protected array $query = array('select' => array(), 'from' => '', 'join' => array(), 'where' => array(), 'group' => array(), 'having' => array(), 'order' => array(), 'limit' => array('offset' => 0, 'limit' => 0))

Methods

__toString

mixed DbQueryCore::__toString()

build

string DbQueryCore::build()

Generate and get the query

from

\DbQuery DbQueryCore::from(string $table, $alias)

Set table for FROM clause

Arguments

  • $table string - Table name
  • $alias mixed

groupBy

\DbQuery DbQueryCore::groupBy(string $fields)

Add a GROUP BY restriction

Arguments

  • $fields string - List of fields to sort. E.g. $this->group('myField, b.mySecondField DESC')

having

\DbQuery DbQueryCore::having(string $restriction)

Add a restriction in HAVING clause (each restriction will be separated by AND statement)

Arguments

  • $restriction string

innerJoin

mixed DbQueryCore::innerJoin(string $table, string $alias, string $on)

Add INNER JOIN clause E.g. $this->innerJoin('product p ON .

..')

Arguments

  • $table string - Table name (without prefix)
  • $alias string - Table alias
  • $on string - ON clause

join

\DbQuery DbQueryCore::join(string $join)

Add JOIN clause E.g. $this->join('RIGHT JOIN '.DB_PREFIX.'product p ON .

..');

Arguments

  • $join string - Complete string

leftJoin

mixed DbQueryCore::leftJoin(string $table, string $alias, string $on)

Add LEFT JOIN clause

Arguments

  • $table string - Table name (without prefix)
  • $alias string - Table alias
  • $on string - ON clause

leftOuterJoin

mixed DbQueryCore::leftOuterJoin(string $table, string $alias, string $on)

Add LEFT OUTER JOIN clause

Arguments

  • $table string - Table name (without prefix)
  • $alias string - Table alias
  • $on string - ON clause

limit

\DbQuery DbQueryCore::limit($limit, $offset)

Limit results in query

Arguments

  • $limit mixed
  • $offset mixed

naturalJoin

mixed DbQueryCore::naturalJoin(string $table, string $alias)

Add NATURAL JOIN clause

Arguments

  • $table string - Table name (without prefix)
  • $alias string - Table alias

orderBy

\DbQuery DbQueryCore::orderBy(string $fields)

Add an ORDER B restriction

Arguments

  • $fields string - List of fields to sort. E.g. $this->order('myField, b.mySecondField DESC')

select

\DbQuery DbQueryCore::select(string $fields)

Add fields in query selection

Arguments

  • $fields string - List of fields to concat to other fields

where

\DbQuery DbQueryCore::where(string $restriction)

Add a restriction in WHERE clause (each restriction will be separated by AND statement)

Arguments

  • $restriction string