Overview

Namespaces

  • None
  • RedBeanPHP
    • Adapter
    • BeanHelper
    • Cursor
    • Driver
    • Logger
      • RDefault
    • QueryWriter
    • RedException
    • Repository
    • Util

Classes

  • RPDO
  • Overview
  • Namespace
  • Class

Class RPDO

PDO Driver This Driver implements the RedBean Driver API. for RedBeanPHP. This is the standard / default database driver for RedBeanPHP.

RedBeanPHP\Driver\RPDO implements RedBeanPHP\Driver
Namespace: RedBeanPHP\Driver
Copyright:

copyright (c) Desfrenes & Gabor de Mooij and the RedBeanPHP community This source file is subject to the BSD/GPLv2 License that is bundled with this source code in the file license.txt.


License: BSD/GPLv2
Author: Gabor de Mooij and the RedBeanPHP Community, Desfrenes
File: RedBeanPHP/PDO.php
Located at Driver/RPDO.php
Methods summary
protected
# bindParams( PDOStatement $statement, array $bindings )

Binds parameters. This method binds parameters to a PDOStatement for Query Execution. This method binds parameters as NULL, INTEGER or STRING and supports both named keys and question mark keys.

Binds parameters. This method binds parameters to a PDOStatement for Query Execution. This method binds parameters as NULL, INTEGER or STRING and supports both named keys and question mark keys.

Parameters

$statement
PDO Statement instance
$bindings
values that need to get bound to the statement
protected mixed
# runQuery( string $sql, array $bindings, array $options = array() )

This method runs the actual SQL query and binds a list of parameters to the query. slots. The result of the query will be stored in the protected property $rs (always array). The number of rows affected (result of rowcount, if supported by database) is stored in protected property $affectedRows. If the debug flag is set this function will send debugging output to screen buffer.

This method runs the actual SQL query and binds a list of parameters to the query. slots. The result of the query will be stored in the protected property $rs (always array). The number of rows affected (result of rowcount, if supported by database) is stored in protected property $affectedRows. If the debug flag is set this function will send debugging output to screen buffer.

Parameters

$sql
the SQL string to be send to database server
$bindings
the values that need to get bound to the query slots
$options

Returns

mixed

Throws

RedBeanPHP\RedException\SQL
protected
# setEncoding( )

Try to fix MySQL character encoding problems. MySQL < 5.5 does not support proper 4 byte unicode but they seem to have added it with version 5.5 under a different label: utf8mb4. We try to select the best possible charset based on your version data.

Try to fix MySQL character encoding problems. MySQL < 5.5 does not support proper 4 byte unicode but they seem to have added it with version 5.5 under a different label: utf8mb4. We try to select the best possible charset based on your version data.

public
# __construct( string|object $dsn, string $user = NULL, string $pass = NULL )

Constructor. You may either specify dsn, user and password or just give an existing PDO connection.

Constructor. You may either specify dsn, user and password or just give an existing PDO connection.

Examples: $driver = new RPDO($dsn, $user, $password); $driver = new RPDO($existingConnection);

Parameters

$dsn
database connection string
$user
optional, usename to sign in
$pass
optional, password for connection login
public string
# getMysqlEncoding( )

Returns the best possible encoding for MySQL based on version data.

Returns the best possible encoding for MySQL based on version data.

Returns

string
public
# setUseStringOnlyBinding( boolean $yesNo )

Whether to bind all parameters as strings. If set to TRUE this will cause all integers to be bound as STRINGS. This will NOT affect NULL values.

Whether to bind all parameters as strings. If set to TRUE this will cause all integers to be bound as STRINGS. This will NOT affect NULL values.

Parameters

$yesNo
pass TRUE to bind all parameters as strings.
public integer
# setMaxIntBind( integer $max )

Sets the maximum value to be bound as integer, normally this value equals PHP's MAX INT constant, however sometimes PDO driver bindings cannot bind large integers as integers. This method allows you to manually set the max integer binding value to manage portability/compatibility issues among different PHP builds. This method will return the old value.

Sets the maximum value to be bound as integer, normally this value equals PHP's MAX INT constant, however sometimes PDO driver bindings cannot bind large integers as integers. This method allows you to manually set the max integer binding value to manage portability/compatibility issues among different PHP builds. This method will return the old value.

Parameters

$max
maximum value for integer bindings

Returns

integer
public
# connect( )

Establishes a connection to the database using PHP\PDO functionality. If a connection has already been established this method will simply return directly. This method also turns on UTF8 for the database and PDO-ERRMODE-EXCEPTION as well as PDO-FETCH-ASSOC.

Establishes a connection to the database using PHP\PDO functionality. If a connection has already been established this method will simply return directly. This method also turns on UTF8 for the database and PDO-ERRMODE-EXCEPTION as well as PDO-FETCH-ASSOC.

public
# setPDO( PDO $pdo )

Directly sets PDO instance into driver. This method might improve performance, however since the driver does not configure this instance terrible things may happen... only use this method if you are an expert on RedBeanPHP, PDO and UTF8 connections and you know your database server VERY WELL.

Directly sets PDO instance into driver. This method might improve performance, however since the driver does not configure this instance terrible things may happen... only use this method if you are an expert on RedBeanPHP, PDO and UTF8 connections and you know your database server VERY WELL.

Parameters

$pdo
PDO instance
public array
# GetAll( string $sql, array $bindings = array() )

Parameters

$sql
SQL query to execute
$bindings
list of values to bind to SQL snippet

Returns

array

See

Driver::GetAll

Implementation of

RedBeanPHP\Driver::GetAll()
public mixed
# GetAssocRow( string $sql, array $bindings = array() )

Parameters

$sql
SQL query to execute
$bindings
list of values to bind to SQL snippet

Returns

mixed

See

Driver::GetAssocRow

Implementation of

RedBeanPHP\Driver::GetAssocRow()
public array
# GetCol( string $sql, array $bindings = array() )

Parameters

$sql
SQL query to execute
$bindings
list of values to bind to SQL snippet

Returns

array

See

Driver::GetCol

Implementation of

RedBeanPHP\Driver::GetCol()
public mixed
# GetOne( string $sql, array $bindings = array() )

Parameters

$sql
SQL query to execute
$bindings
list of values to bind to SQL snippet

Returns

mixed

See

Driver::GetOne

Implementation of

RedBeanPHP\Driver::GetOne()
public mixed
# GetCell( string $sql, array $bindings = array() )

Alias for getOne(). Backward compatibility.

Alias for getOne(). Backward compatibility.

Parameters

$sql
SQL
$bindings
bindings

Returns

mixed
public array
# GetRow( string $sql, array $bindings = array() )

Parameters

$sql
SQL query to execute
$bindings
list of values to bind to SQL snippet

Returns

array

See

Driver::GetRow

Implementation of

RedBeanPHP\Driver::GetRow()
public array
# Execute( string $sql, array $bindings = array() )

Parameters

$sql
SQL query to execute
$bindings
list of values to bind to SQL snippet

Returns

array
Affected Rows

See

Driver::Excecute

Implementation of

RedBeanPHP\Driver::Execute()
public integer
# GetInsertID( )

Returns

integer

See

Driver::GetInsertID

Implementation of

RedBeanPHP\Driver::GetInsertID()
public mixed
# GetCursor( string $sql, array $bindings = array() )

Parameters

$sql
SQL query to execute
$bindings
list of values to bind to SQL snippet

Returns

mixed

See

Driver::GetCursor

Implementation of

RedBeanPHP\Driver::GetCursor()
public integer
# Affected_Rows( )

Returns

integer

See

Driver::Affected_Rows

Implementation of

RedBeanPHP\Driver::Affected_Rows()
public
# setDebugMode( boolean $tf, RedBeanPHP\Logger $logger = NULL )

Toggles debug mode. In debug mode the driver will print all SQL to the screen together with some information about the results.

Toggles debug mode. In debug mode the driver will print all SQL to the screen together with some information about the results.

Parameters

$tf
$trueFalse turn on/off
$logger
logger instance

Implementation of

RedBeanPHP\Driver::setDebugMode()
public
# setLogger( RedBeanPHP\Logger $logger )

Injects Logger object. Sets the logger instance you wish to use.

Injects Logger object. Sets the logger instance you wish to use.

Parameters

$logger
the logger instance to be used for logging
public RedBeanPHP\Logger
# getLogger( )

Gets Logger object. Returns the currently active Logger instance.

Gets Logger object. Returns the currently active Logger instance.

Returns

RedBeanPHP\Logger
public
# StartTrans( )

See

Driver::StartTrans

Implementation of

RedBeanPHP\Driver::StartTrans()
public
# CommitTrans( )

See

Driver::CommitTrans

Implementation of

RedBeanPHP\Driver::CommitTrans()
public
# FailTrans( )

See

Driver::FailTrans

Implementation of

RedBeanPHP\Driver::FailTrans()
public string
# getDatabaseType( )

Returns the name of database driver for PDO. Uses the PDO attribute DRIVER NAME to obtain the name of the PDO driver.

Returns the name of database driver for PDO. Uses the PDO attribute DRIVER NAME to obtain the name of the PDO driver.

Returns

string
public mixed
# getDatabaseVersion( )

Returns the version number of the database.

Returns the version number of the database.

Returns

mixed
public PDO
# getPDO( )

Returns the underlying PHP PDO instance.

Returns the underlying PHP PDO instance.

Returns

PDO
public
# close( )

Closes database connection by destructing PDO.

Closes database connection by destructing PDO.

public boolean
# isConnected( )

Returns TRUE if the current PDO instance is connected.

Returns TRUE if the current PDO instance is connected.

Returns

boolean
public RedBeanPHP\Driver\RPDO
# setEnableLogging( boolean $enable )

Toggles logging, enables or disables logging.

Toggles logging, enables or disables logging.

Parameters

$enable
TRUE to enable logging

Returns

RedBeanPHP\Driver\RPDO
public RedBeanPHP\Driver\RPDO
# resetCounter( )

Resets the internal Query Counter.

Resets the internal Query Counter.

Returns

RedBeanPHP\Driver\RPDO

Implementation of

RedBeanPHP\Driver::resetCounter()
public integer
# getQueryCount( )

Returns the number of SQL queries processed.

Returns the number of SQL queries processed.

Returns

integer

Implementation of

RedBeanPHP\Driver::getQueryCount()
public integer
# getIntegerBindingMax( )

Returns the maximum value treated as integer parameter binding.

Returns the maximum value treated as integer parameter binding.

This method is mainly for testing purposes but it can help you solve some issues relating to integer bindings.

Returns

integer
Properties summary
protected integer $max
#
protected string $dsn
#
protected boolean $loggingEnabled
# FALSE
protected RedBeanPHP\Logger $logger
# NULL
protected PDO $pdo
#
protected integer $affectedRows
#
protected integer $resultArray
#
protected array $connectInfo
# array()
protected boolean $isConnected
# FALSE
protected boolean $flagUseStringOnlyBinding
# FALSE
protected integer $queryCounter
# 0
protected string $mysqlEncoding
# ''
API documentation generated by ApiGen