API Documentation for: 1.1.1
Show:

SelectQuery Class

Extends Query
Namespace: Canteen\Database

Represents a SELECT SQL statement

$users = $db->select('first_name')
    ->from('users')
    ->where('user_id=1')
    ->results();

Constructor

SelectQuery

(
  • db
  • tables
)

Parameters:

  • db Database

    Reference to the database

  • tables Array | String multiple

    The properties as array or list of args or string

Methods

__toString

() String

Represent the query as a SQL statement

Returns:

String:

The query in SQL string form

escape

(
  • value
)
String | Array protected

Inherited from Query:

Convenience function for escapeString method on Database

Parameters:

  • value String | Array

    The value or collection of values

Returns:

String | Array:

The value or collection of values

from

(
  • args
)
SelectQuery

Select from the tables

Parameters:

  • args String | Array multiple

    The string of table or a collection of tables (array or n args)

Returns:

SelectQuery:

Instance of this query

groupBy

(
  • args
)
SelectQuery

Group the selection

Parameters:

  • args String | Array multiple

    Group by name either array, string or list of arguments

Returns:

SelectQuery:

Instance of this query

length

(
  • [cache=false]
)
Int

Get the number of rows

Parameters:

  • [cache=false] Boolean optional

    If we should cache the result

Returns:

Int:

The number of rows by selection

limit

(
  • lengthOrIndex
  • [duration=null]
)
Query

Inherited from Query:

The limit for query

Parameters:

  • lengthOrIndex Int

    Either the single limit number or index, duration

  • [duration=null] Int optional

    How many rows to fetch

Returns:

Query:

The instance of this query

orderBy

(
  • field
  • [order='asc']
)
Query

Inherited from Query:

How to order the results by

Parameters:

  • field String

    The property field

  • [order='asc'] String optional

    The order, either ASC or DESC

Returns:

Query:

The instance of this query

prepare

(
  • value
)
String protected

Inherited from Query:

Take an existing value we're about to input and escape it, if needed

Parameters:

  • value String

    A statement or sql property to evaluate

Returns:

String:

A string of an escaped, prepared SQL property

prepareField

(
  • field
)
String protected

Inherited from Query:

Take an existing field name we're about to input and

Parameters:

  • field String

    The name of a field

Returns:

String:

A string of an escaped, prepared SQL field name

result

() Boolean

Inherited from Query:

Execute the query

Returns:

Boolean:

If result was successful

results

(
  • [cache=false]
)
Array

Select all of the results

Parameters:

  • [cache=false] Boolean optional

    If we should cache the result

Returns:

Array:

Get array of row items

row

(
  • [cache=false]
)
Array

Get the row of data

Parameters:

  • [cache=false] Boolean optional

    If we should cache the result

Returns:

Array:

The array of values for this row

setTables

(
  • tables
)
Query protected

Inherited from Query:

Create and insert query

Parameters:

  • tables Array | String multiple

    The table to insert into

Returns:

Query:

The instance of this query

where

(
  • args
)
Query

Inherited from Query:

Do a where selection

Parameters:

  • args Array | String multiple

    A single where statement or array of and statements, or list of arguments

Returns:

Query:

The instance of this query

Properties

db

Database protected

Inherited from Query:

The reference to the database connection, required!

limit

String protected

Inherited from Query:

The limit

orderBy

String protected

Inherited from Query:

The order by

tables

String protected

Inherited from Query:

The table or tables to insert into

where

String protected

Inherited from Query:

The array collection of where properties