Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Record

Class Record

General purpose Database access object

Model
Extended by Record
Package: minPHP\components\record
Located at components/record/record.php

Methods summary

public static stdClass
# keywordValue( string $keyword = "DEFAULT" )

Returns a stdClass object used to identify keyword values (i.e. DEFAULT) that can be set in Record and that should never be bound or escaped

Returns a stdClass object used to identify keyword values (i.e. DEFAULT) that can be set in Record and that should never be bound or escaped

Parameters

$keyword
string
$keyword The name of the keyword to set

Returns

stdClass
An object used to identify the keyword value
public reference
# setField( string $name, array $attributes = null, boolean $add = true )

Sets a field with various options

Sets a field with various options

Parameters

$name
string
$name The name of the field
$attributes
array
$attributes An array of attributes that may contain the following: - type The type of field - size The size of the field. If type is "varchar" size could be "64" to produce "varchar(64)" (optional) - unsigned Set to true to set this field as unsigned (optional) - auto_increment Set to true to set this field to auto_increment (optional) - default Used to define a default value for the field (optional) - is_null Set to true if this field
$add
boolean
$add True to add the field, false to drop the field

Returns

reference
to this
public reference
# setKey( array $fields, string $type, string $name = null, boolean $add = true )

Sets a key to be added to the table being created or altered

Sets a key to be added to the table being created or altered

Parameters

$fields
array
$fields A numerical array of fields to set as a key
$type
string
$type The type of key ("index", "primary", "unique")
$name
string
$name The name of the key, will default to the first value in $fields if null
$add
boolean
$add True to add the key, false to drop the key

Returns

reference
to this
public PDOStatement
# create( string $table, boolean $if_not_exists = false )

Creates a table with the given name

Creates a table with the given name

Parameters

$table
string
$table The name of the table to create
$if_not_exists
boolean
$if_not_exists If true will create the table IFF the table does not exist

Returns

PDOStatement
public PDOStatement
# alter( string $table )

Alters a table with the given name

Alters a table with the given name

Parameters

$table
string
$table The name of the table to alter

Returns

PDOStatement
public PDOStatement
# truncate( string $table )

Truncates a table with the given name

Truncates a table with the given name

Parameters

$table
string
$table The name of the table to truncate

Returns

PDOStatement
public PDOStatement
# drop( string $table, boolean $if_exists = false )

Drops a table with the given name

Drops a table with the given name

Parameters

$table
string
$table The name of the table to create
$if_exists
boolean
$if_exists If true will drop the table only if it exists

Returns

PDOStatement
public
# set( string $field, string $value, boolean $bind_value = true, boolean $escape = true )

Set fields for inserting or updating

Set fields for inserting or updating

Parameters

$field
string
$field The field name, or table.field name
$value
string
$value The value to set or insert into this field
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise
public PDOStatement
# insert( string $table, array $values = null, array $value_keys = null )

Inserts values into a table

Inserts values into a table

Parameters

$table
string
$table The table name to insert
$values
array
$values The field/value pairs to insert into this table
$value_keys
array
$value_keys An array of keys reperesenting fields to accept for insertion

Returns

PDOStatement

See

Record::set()
public PDOStatement
# update( string $table, array $values = null, array $value_keys = null )

Updates values in a table

Updates values in a table

Parameters

$table
string
$table The table to update
$values
array
$values The field/value pairs to update in this table
$value_keys

Returns

PDOStatement

See

Record::set()
public PDOStatement
# delete( array $columns = null, boolean $escape = true )

Deletes columns from the currently-set tables

Deletes columns from the currently-set tables

Parameters

$columns
array
$columns The tables to delete from, null to delete from all
$escape
boolean
$escape True to escape $columns, false otherwise

Returns

PDOStatement
public reference
# select( mixed $columns = "*", boolean $escape = true )

Sets the columns to select from

Sets the columns to select from

Parameters

$columns
mixed
$columns The table columns to select, or a string containing a single column
$escape
boolean
$escape True to escape $columns, false otherwise

Returns

reference
to this
public reference
# from( mixed $table )

Sets the tuples to query from

Sets the tuples to query from

Parameters

$table
mixed
$table The table (string) or subqueries (array) to query from

Returns

reference
to this
public reference
# join( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )

Sets the tables to join on into a sql statement

Sets the tables to join on into a sql statement

Parameters

$table
string
$table The table to join on
$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# leftJoin( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )

Sets the tables to join on into a sql statement

Sets the tables to join on into a sql statement

Parameters

$table
string
$table The table to join on
$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# rightJoin( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )

Sets the tables to join on into a sql statement

Sets the tables to join on into a sql statement

Parameters

$table
string
$table The table to join on
$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# innerJoin( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )

Sets the tables to join on into a sql statement

Sets the tables to join on into a sql statement

Parameters

$table
string
$table The table to join on
$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# on( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the "on" conditional for the next join statement

Sets the "on" conditional for the next join statement

Parameters

$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# orOn( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the "on" conditional as an "or" option for the next join statement

Sets the "on" conditional as an "or" option for the next join statement

Parameters

$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# where( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the where condition of a query with an AND statement

Sets the where condition of a query with an AND statement

Parameters

$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# orWhere( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the where condition of a query with an OR statement

Sets the where condition of a query with an OR statement

Parameters

$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# duplicate( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the on duplicate key condition of a query

Sets the on duplicate key condition of a query

Parameters

$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# like( string $field, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the where condition of a query with a LIKE statement on AND

Sets the where condition of a query with a LIKE statement on AND

Parameters

$field
string
$field The field for comparison
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# notLike( string $field, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the where condition of a query with a NOT LIKE statement on AND

Sets the where condition of a query with a NOT LIKE statement on AND

Parameters

$field
string
$field The field for comparison
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# orLike( string $field, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the where condition of a query with a LIKE statement on OR

Sets the where condition of a query with a LIKE statement on OR

Parameters

$field
string
$field The field for comparison
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# orNotLike( string $field, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the where condition of a query with a NOT LIKE statement on OR

Sets the where condition of a query with a NOT LIKE statement on OR

Parameters

$field
string
$field The field for comparison
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# having( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the having condition of a query with an AND statement

Sets the having condition of a query with an AND statement

Parameters

$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# orHaving( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )

Sets the having condition of a query with an OR statement

Sets the having condition of a query with an OR statement

Parameters

$field
string
$field The field for comparison
$op
string
$op The operator to compare on
$value
string
$value The value to compare with
$bind_value
boolean
$bind_value True to treat $value as a bound value (i.e. a string or integer, rather than an table or table field)
$escape
boolean
$escape True to escape the value, false otherwise

Returns

reference
to this
public reference
# group( mixed $columns )

Sets the columns to group by

Sets the columns to group by

Parameters

$columns
mixed
$columns The column (string) or columns (array) to group by

Returns

reference
to this
public reference
# order( array $fields, mixed $escape = true )

Sets the fields to order by

Sets the fields to order by

Parameters

$fields
array
$fields The fields to order by
$escape

Returns

reference
to this
public reference
# limit( unsigned $records, unsigned $start = 0 )

Sets limits on the records of a query

Sets limits on the records of a query

Parameters

$records
unsigned
integer $records The number of records to retrieve
$start
unsigned
integer $start The record to start on (optional, default 0)

Returns

reference
to this
public mixed
# fetch( )

Fetch a single row from the query

Fetch a single row from the query

Returns

mixed
The return value on success depends on the fetch type. In all cases, false is returned on failure.

See

PDOStatement::fetch()
PDOStatement::setFetchMode()
public mixed
# fetchAll( )

Fetch all rows from the query

Fetch all rows from the query

Returns

mixed
An array containing all of hte remaining rows in the result set, false on failure.

See

PDOStatement::fetchAll()
PDOStatement::setFetchMode()
public PDOStatement
# getStatement( )

Executes the query and returns the PDOStatment object

Executes the query and returns the PDOStatment object

Returns

PDOStatement
The executed statement object that may be iterated over
public string
# get( )

Converts the Record object to a query string. This differs from Record::__toString() in that member variables are not restored to their state prior to the method call, therefore this method may prove more useful when constructing subqueries.

Converts the Record object to a query string. This differs from Record::__toString() in that member variables are not restored to their state prior to the method call, therefore this method may prove more useful when constructing subqueries.

Returns

string
The SQL query

See

Record::__toString()
public string
# __toString( )

Converts the Record object to a query string. This differs from Record::get() in that member variables are restored to their state prior to the method call.

Converts the Record object to a query string. This differs from Record::get() in that member variables are restored to their state prior to the method call.

Returns

string
The SQL query

See

Record::get()
public integer
# numResults( )

Returns the number of results from the given query. This essentially wraps the query into a new (sub) query, and returns a COUNT on that result

Returns the number of results from the given query. This essentially wraps the query into a new (sub) query, and returns a COUNT on that result

Returns

integer
The number of results from the given query
public reference
# open( )

Modifies the next where statement so that it beings with an open parenthese

Modifies the next where statement so that it beings with an open parenthese

Returns

reference
to this
public reference
# close( string $conditional = "where" )

Modifies the given coditional statement to end with a close parenthese

Modifies the given coditional statement to end with a close parenthese

Parameters

$conditional
string
$conditional The conditional to close ("where", "on", "having", "duplicate")

Returns

reference
to this
public refe
# appendValues( array $values )

Appends the given values to the values array so that they may be applied in the given order.

Appends the given values to the values array so that they may be applied in the given order.

Parameters

$values
array
$values An array of values to append to the existing array of values

Returns

refe
to this
public
# reset( )

Reset the object, making ready for the next query

Reset the object, making ready for the next query

public string
# quoteIdentifier( mixed $identifier )

Escapes identifiers in the format of table.field or field, or an array of the form array('table', 'field')

Escapes identifiers in the format of table.field or field, or an array of the form array('table', 'field')

Parameters

$identifier
mixed
A string identifier or an array of identifier parts

Returns

string
A string representing the quoted identifier

Methods inherited from Model

__construct(), affectedRows(), begin(), commit(), getConnection(), lastInsertId(), makeDSN(), prepare(), query(), rollBack(), setAttribute(), setFetchMode()

Magic methods summary

Properties summary

protected string $ident_quote_chr
#

The character to use to quote identifiers

The character to use to quote identifiers

public array $values
#

All values, in the order added appended to the PDO::query() method

All values, in the order added appended to the PDO::query() method

Blesta API documentation generated by ApiGen 2.8.0