API Documentation for: 1.1.1
Show:

Query Class

Namespace: Canteen\Database

The abstract class that all queries extend this is base API for creating database queries

Constructor

Query

(
  • db
)

Parameters:

  • db Database

    The reference to the database connection

Methods

escape

(
  • value
)
String | Array protected

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

limit

(
  • lengthOrIndex
  • [duration=null]
)
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

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

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

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

Execute the query

Returns:

Boolean:

If result was successful

setTables

(
  • tables
)
Query protected

Create and insert query

Parameters:

  • tables Array | String multiple

    The table to insert into

Returns:

Query:

The instance of this query

where

(
  • args
)
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

The reference to the database connection, required!

limit

String protected

The limit

orderBy

String protected

The order by

tables

String protected

The table or tables to insert into

where

String protected

The array collection of where properties