Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
StudipPDO Class Reference
Inheritance diagram for StudipPDO:
TestStudipPDO

Public Member Functions

 quote ($value, $type=null)
 
 exec ($statement)
 
 query ($statement, $fetch_mode=NULL,...$fetch_args)
 
 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)
 
 isMariaDB ()
 

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 (   $statement)

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

Parameters
stringSQL statement
Returns
int number of affected rows
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
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
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
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
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
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
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
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
isMariaDB ( )

Determine if the connected database is a MariaDB database.

Returns
bool
prepare (   $statement,
  $driver_options = [] 
)

Prepares a statement for execution and returns a statement object.

Parameters
stringSQL statement
Returns
object PDOStatement object
prepareStatement (   $statement,
  $driver_options = [] 
)

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

Parameters
stringSQL statement
Returns
object PDOStatement object
query (   $statement,
  $fetch_mode = NULL,
  $fetch_args 
)

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

Parameters
string$statementSQL statement
int$fetch_modefetch mode (optional)
mixed...$fetch_args fetch mode parameters (see PDOStatement::setFetchMode)
Returns
object PDOStatement object
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
mixed$valuePHP value to quote
?int$type parameter type (e.g. PDO::PARAM_STR)
Returns
string quoted SQL string
static replaceStrings (   $statement)
staticprotected

Replaces all string literals in the statement with placeholders.

Parameters
stringSQL statement
Returns
string modified SQL statement
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

Field Documentation

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

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