Stud.IP  trunk Revision
StudipPDO Class Reference
Inheritance diagram for StudipPDO:
Inheritance graph
Collaboration diagram for StudipPDO:
Collaboration graph

Public Member Functions

 quote ($value, $type=NULL)
 
 exec ($statement)
 
 query ($statement, $mode=NULL, $arg1=NULL, $arg2=NULL)
 
 prepare ($statement, $driver_options=[])
 
 prepareStatement ($statement, $driver_options=[])
 
 execute ($statement, $input_parameters=null)
 
 fetchAll ($statement, $input_parameters=null, $callable=null)
 
 fetchFirst ($statement, $input_parameters=null, $callable=null)
 
 fetchGrouped ($statement, $input_parameters=null, $callable=null)
 
 fetchGroupedPairs ($statement, $input_parameters=null, $callable=null)
 
 fetchPairs ($statement, $input_parameters=null, $callable=null)
 
 fetchOne ($statement, $input_parameters=null)
 
 fetchColumn ($statement, $input_parameters=null, $column=0)
 

Data Fields

const PARAM_ARRAY = 100
 
const PARAM_COLUMN = 101
 
 $query_count = 0
 
 $queries = []
 

Protected Member Functions

 verify ($statement)
 

Static Protected Member Functions

static replaceStrings ($statement)
 

Detailed Description

This is a special variant of the standard PDO class that does not allow multiple statement execution.

Member Function Documentation

◆ exec()

exec (   $statement)

Executes an SQL statement and returns the number of affected rows.

Parameters
stringSQL statement
Returns
int number of affected rows
Here is the call graph for this function:

◆ execute()

execute (   $statement,
  $input_parameters = null 
)

Executes sql statement with given parameters, returns number of affected rows, use only for INSERT,UPDATE etc

Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
Returns
integer number of affected rows
Here is the call graph for this function:

◆ fetchAll()

fetchAll (   $statement,
  $input_parameters = null,
  $callable = null 
)

Executes sql statement with given parameters, and fetch results as sequential array, each row as associative array optionally apply given callable on each row, with current row and key as parameter

Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
callable$callablecallable to be applied to each of the rows
Returns
array result set as array of assoc arrays
Here is the call graph for this function:

◆ fetchColumn()

fetchColumn (   $statement,
  $input_parameters = null,
  $column = 0 
)

Executes sql statement with given parameters, and fetch only the value of one column third param denotes the column, zero indexed

Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
integer$columnnumber of column to fetch
Returns
string value of chosen column
Here is the call graph for this function:

◆ fetchFirst()

fetchFirst (   $statement,
  $input_parameters = null,
  $callable = null 
)

Executes sql statement with given parameters, and fetch only the values from first column as sequential array optionally apply given callable on each row, with current value and key as parameter

See also
StudipPDOStatement::fetchFirst()
Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
callable$callablecallable to be applied to each of the rows
Returns
array result set
Here is the call graph for this function:

◆ fetchGrouped()

fetchGrouped (   $statement,
  $input_parameters = null,
  $callable = null 
)

Executes sql statement with given parameters, and fetch results as associative array, first columns value is used as a key, the others are grouped optionally apply given callable on each grouped row, with current row and key as parameter if no callable is given, 'current' is used, to return the first entry of the grouped row

See also
StudipPDOStatement::fetchGrouped()
Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
callable$callablecallable to be applied to each of the rows
Returns
array result set
Here is the call graph for this function:

◆ fetchGroupedPairs()

fetchGroupedPairs (   $statement,
  $input_parameters = null,
  $callable = null 
)

Executes sql statement with given parameters, and fetch results as associative array, first columns value is used as a key, the other one is grouped use only when selecting 2 columns optionally apply given callable on each grouped row, with current row and key as parameter

See also
StudipPDOStatement::fetchGroupedPairs()
Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
callable$callablecallable to be applied to each of the rows
Returns
array result set
Here is the call graph for this function:

◆ fetchOne()

fetchOne (   $statement,
  $input_parameters = null 
)

Executes sql statement with given parameters, and fetch only the first row as associative array

See also
StudipPDOStatement::fetchOne()
Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
Returns
array first row of result set
Here is the call graph for this function:

◆ fetchPairs()

fetchPairs (   $statement,
  $input_parameters = null,
  $callable = null 
)

Executes sql statement with given parameters, and fetch results as associative array, first columns value is used as a key, the other one as the value use only when selecting 2 columns optionally apply given callable on each grouped row, with current row and key as parameter

See also
StudipPDOStatement::fetchGroupedPairs()
Parameters
string$statementSQL statement to execute
array$input_parametersparameters for statement
callable$callablecallable to be applied to each of the rows
Returns
array result set
Here is the call graph for this function:

◆ prepare()

prepare (   $statement,
  $driver_options = [] 
)

Prepares a statement for execution and returns a statement object.

Parameters
stringSQL statement
Returns
object PDOStatement object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareStatement()

prepareStatement (   $statement,
  $driver_options = [] 
)

This method is intended only for use by the StudipPDOStatement class.

Parameters
stringSQL statement
Returns
object PDOStatement object

◆ query()

query (   $statement,
  $mode = NULL,
  $arg1 = NULL,
  $arg2 = NULL 
)

Executes an SQL statement, returning a result set as a statement object.

Parameters
stringSQL statement
intfetch mode (optional)
mixedfetch mode parameter (see PDOStatement::setFetchMode)
mixedfetch mode parameter (see PDOStatement::setFetchMode)
Returns
object PDOStatement object
Here is the call graph for this function:

◆ quote()

quote (   $value,
  $type = NULL 
)

Quotes the given value in a form appropriate for the type. If no explicit type is given, the value's PHP type is used.

Parameters
stringPHP value to quote
intparameter type (e.g. PDO::PARAM_STR)
Returns
string quoted SQL string

◆ replaceStrings()

static replaceStrings (   $statement)
staticprotected

Replaces all string literals in the statement with placeholders.

Parameters
stringSQL statement
Returns
string modified SQL statement

◆ verify()

verify (   $statement)
protected

Verifies that the given SQL query only contains a single statement.

Parameters
stringSQL statement to check
Exceptions
PDOExceptionwhen the query contains multiple statements
Here is the caller graph for this function:

Field Documentation

◆ $queries

$queries = []

◆ $query_count

$query_count = 0

◆ PARAM_ARRAY

const PARAM_ARRAY = 100

◆ PARAM_COLUMN

const PARAM_COLUMN = 101

The documentation for this class was generated from the following file: