Overview

Namespaces

  • None
  • PHP

Classes

  • AbstractTest
  • AMysql
  • AMysql_Abstract
  • AMysql_Expr
  • AMysql_Iterator
  • AMysql_Profiler
  • AMysql_Select
  • AMysql_Statement
  • AMysql_TestCase
  • ExceptionTest
  • ExprTest
  • IteratorTest
  • SelectTest
  • StatementTest

Exceptions

  • AMysql_Exception
  • Overview
  • Namespace
  • Class
  • Tree

Class AMysql_Expr

Class for making custom expressions for AMysql value binding. This is what you should use to be able to add specific kinds of purposely unquoted, non-numeric values into prepared statements, such as being able to call mysql functions to set values.

This class can be extended and is recommended to do so if you want custom expressions; in which case you would have to manually instatiate that class each time, rather than using AMysql::expr()

Expression codes 0-999 should be considered reserved to this class; if you extend this class, please use at least 1000 as expression code ints.

Visit https://github.com/amcsi/amysql

License: License; http://www.opensource.org/licenses/mit-license.php
Author: Szerémi Attila
Created: 2011.06.10. 13:26:56
Located at AMysql/Expr.php
Methods summary
public
# __construct( )

Constructor

This constructor accepts different parameters in different cases. Before everything, if the first parameter is an AMysql instance, it is saved, and is shifted from the arguments array, and the following applies in either case: The first parameter is mandatory: the one that gives the type of expression. The types of expressions can be found as constants on this class, and their documentation can be found above each constant type declaration.

Params

...$variadic In case of a literal string, you can just pass the literal string as the only parameter.
public
# set( )
protected string
# setByArray( array $args )

This method performs the logic of determining what the expression should result in. When extending this class, it is recommended that you override this method, determine whether the expression code is something that you want to handle, otherwise call and return the parent's setByArray() method

This method performs the logic of determining what the expression should result in. When extending this class, it is recommended that you override this method, determine whether the expression code is something that you want to handle, otherwise call and return the parent's setByArray() method

Parameters

$args
array
$args The first index should contain the type of expression to use, the rest depends on the type of expression. See the class constants for available types.

Returns

string
The literal string to use
public
# escapeTable( mixed $table )
public
# escapeColumn( mixed $column )
public
# toString( )
public string
# __toString( )

Returns the literal string this expression should resolve to.

Returns the literal string this expression should resolve to.

Returns

string
Constants summary
integer LITERAL 0
#

Literal string

Literal string

e.g. $currentTimestampBind = new AMysql_Expr( AMysql_Expr::LITERAL, 'CURRENT_TIMESPAMP' ); // or $currentTimestampBind = new AMysql_Expr('CURRENT_TIMESTAMP');

integer EXPR_LITERAL 0
#
integer COLUMN_IN 1
#

IN() function. In this case, the 2nd parameter is the table name, the third is the array of values

IN() function. In this case, the 2nd parameter is the table name, the third is the array of values

e.g. $idIn = new AMysql_Expr(AMysql_Expr::COLUMN_IN, 'id', array ( '3', '4', '6' ));

integer EXPR_COLUMN_IN 1
#
integer ESCAPE_LIKE 2
#

Escapes wildcards for a LIKE statement. The second parameter has to be the string to escape, and the third is optional, and is the sprintf format of the string, where literal wildcards should appear. The default is %%%s%%, where the input of "something" will result in: "'%something%' ESCAPE '='"

Escapes wildcards for a LIKE statement. The second parameter has to be the string to escape, and the third is optional, and is the sprintf format of the string, where literal wildcards should appear. The default is %%%s%%, where the input of "something" will result in: "'%something%' ESCAPE '='"

integer ESCAPE_TABLE 3
#

Escapes a table name and encloses it in quotes. The second parameter is the table name.

Escapes a table name and encloses it in quotes. The second parameter is the table name.

integer EXPR_TABLE 3
#
integer ESCAPE_COLUMN 4
#

Escapes a column name and encloses it in quotes. The second parameter is the column name.

Escapes a column name and encloses it in quotes. The second parameter is the column name.

integer EXPR_COLUMN 4
#
Properties summary
public mixed $prepared
#
public mixed $amysql
#
API documentation generated by ApiGen 2.8.0