Stud.IP  5.4
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()

exec (   $statement)

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

Parameters
stringSQL statement
Returns
int|false number of affected rows

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ isMariaDB()

isMariaDB ( )

Determine if the connected database is a MariaDB database.

Returns
bool

◆ prepare()

prepare (   $statement,
  $driver_options = [] 
)

Prepares a statement for execution and returns a statement object.

Parameters
string$statementSQL statement
array$driver_options
Returns
StudipPDOStatement

◆ 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,
  $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()

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|false 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

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: