Skip to content

Latest commit

 

History

History
1148 lines (599 loc) · 23.1 KB

class.DbPDOCore.md

File metadata and controls

1148 lines (599 loc) · 23.1 KB

Class DbPDOCore

Contents

Properties

Methods

Properties

$_servers

protected array $_servers = array()

$database

protected string $database

$instance

protected array $instance = array()

$is_cache_enabled

protected boolean $is_cache_enabled

$last_cached

protected string $last_cached

Last cached query

$last_query

protected string $last_query

Store last executed query

$link

protected mixed $link

$password

protected string $password

$result

protected mixed $result

$server

protected string $server

$user

protected string $user

Methods

Affected_Rows

mixed DbPDOCore::Affected_Rows()

Insert_ID

mixed DbPDOCore::Insert_ID()

__construct

mixed DbCore::__construct(string $server, string $user, string $password, string $database, boolean $connect)

Instantiate database connection

Arguments

  • $server string - Server address
  • $user string - User login
  • $password string - User password
  • $database string - Database name
  • $connect boolean - If false, don't connect in constructor (since 1.5.0)

__destruct

mixed DbCore::__destruct()

Close connection to database

_escape

mixed DbPDOCore::_escape($str)

Arguments

  • $str mixed

_getPDO

mixed DbPDOCore::_getPDO($host, $user, $password, $dbname, $timeout)

Arguments

  • $host mixed
  • $user mixed
  • $password mixed
  • $dbname mixed
  • $timeout mixed

_numRows

mixed DbPDOCore::_numRows($result)

Arguments

  • $result mixed

_query

mixed DbPDOCore::_query($sql)

Arguments

  • $sql mixed

autoExecute

mixed DbCore::autoExecute($table, $data, $type, $where, $limit, $use_cache, $use_null)

Arguments

  • $table mixed
  • $data mixed
  • $type mixed
  • $where mixed
  • $limit mixed
  • $use_cache mixed
  • $use_null mixed

autoExecuteWithNullValues

mixed|boolean DbCore::autoExecuteWithNullValues(string $table, string $values, string $type, string $where, integer $limit)

Filter SQL query within a blacklist

Arguments

  • $table string - Table where insert/update data
  • $values string - Data to insert/update
  • $type string - INSERT or UPDATE
  • $where string - WHERE clause, only for UPDATE (optional)
  • $limit integer - LIMIT clause (optional)

checkConnection

integer DbCore::checkConnection(string $server, string $user, string $pwd, string $db, boolean $new_db_link, boolean $engine, $timeout)

Try a connection to te database

Arguments

  • $server string - Server address
  • $user string - Login for database connection
  • $pwd string - Password for database connection
  • $db string - Database name
  • $new_db_link boolean
  • $engine boolean
  • $timeout mixed

checkCreatePrivilege

mixed DbPDOCore::checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)

Arguments

  • $server mixed
  • $user mixed
  • $pwd mixed
  • $db mixed
  • $prefix mixed
  • $engine mixed

checkEncoding

integer DbCore::checkEncoding(string $server, string $user, string $pwd)

Try a connection to te database

Arguments

  • $server string - Server address
  • $user string - Login for database connection
  • $pwd string - Password for database connection

connect

mixed DbPDOCore::connect()

createDatabase

mixed DbPDOCore::createDatabase($host, $user, $password, $dbname, $dropit)

Arguments

  • $host mixed
  • $user mixed
  • $password mixed
  • $dbname mixed
  • $dropit mixed

delete

boolean DbCore::delete(string $table, string $where, integer $limit, boolean $use_cache, boolean $add_prefix)

Execute a DELETE query

Arguments

  • $table string - Name of the table to delete
  • $where string - WHERE clause on query
  • $limit integer - Number max of rows to delete
  • $use_cache boolean - Use cache or not
  • $add_prefix boolean - Add or not DB_PREFIX before table name

disconnect

mixed DbPDOCore::disconnect()

displayError

mixed DbCore::displayError(boolean $sql)

Display last SQL error

Arguments

  • $sql boolean

ds

mixed DbCore::ds($sql, $use_cache)

Arguments

  • $sql mixed
  • $use_cache mixed

escape

string DbCore::escape(string $string, boolean $html_ok)

Sanitize data which will be injected into SQL query

Arguments

  • $string string - SQL data which will be injected into SQL query
  • $html_ok boolean - Does data contain HTML code ? (optional)

execute

boolean DbCore::execute(string $sql, boolean $use_cache)

Execute a query

Arguments

  • $sql string
  • $use_cache boolean

executeS

array DbCore::executeS(string $sql, boolean $array, boolean $use_cache)

ExecuteS return the result of $sql as array

Arguments

  • $sql string - query to execute
  • $array boolean - return an array instead of a mysql_result object (deprecated since 1.5.0, use query method instead)
  • $use_cache boolean - if query has been already executed, use its result

getBestEngine

mixed DbPDOCore::getBestEngine()

getClass

string DbCore::getClass()

Get child layer class

getInstance

\Db DbCore::getInstance(boolean $master)

Get Db object instance

Arguments

  • $master boolean - Decides whether the connection to be returned by the master server or the slave server

getMsgError

mixed DbPDOCore::getMsgError($query)

Arguments

  • $query mixed

getNumberError

mixed DbPDOCore::getNumberError()

getRow

array DbCore::getRow(mixed $sql, boolean $use_cache)

getRow return an associative array containing the first row of the query This function automatically add "limit 1" to the query

Arguments

  • $sql mixed - the select query (without "LIMIT 1")
  • $use_cache boolean - find it in cache first

getValue

mixed DbCore::getValue(mixed $sql, boolean $use_cache)

getValue return the first item of a select query.

Arguments

  • $sql mixed
  • $use_cache boolean

getVersion

mixed DbPDOCore::getVersion()

hasTableWithSamePrefix

mixed DbPDOCore::hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix)

Arguments

  • $server mixed
  • $user mixed
  • $pwd mixed
  • $db mixed
  • $prefix mixed

insert

boolean DbCore::insert(string $table, array $data, boolean $null_values, boolean $use_cache, integer $type, boolean $add_prefix)

Execute an INSERT query

Arguments

  • $table string - Table name without prefix
  • $data array - Data to insert as associative array. If $data is a list of arrays, multiple insert will be done
  • $null_values boolean - If we want to use NULL values instead of empty quotes
  • $use_cache boolean
  • $type integer - Must be Db::INSERT or Db::INSERT_IGNORE or Db::REPLACE
  • $add_prefix boolean - Add or not DB_PREFIX before table name

loadSlaveServers

mixed DbCore::loadSlaveServers()

nextRow

mixed DbPDOCore::nextRow($result)

Arguments

  • $result mixed

numRows

integer DbCore::numRows()

Get number of rows for last result

ps

mixed DbCore::ps($sql, $use_cache)

Arguments

  • $sql mixed
  • $use_cache mixed

q

mixed DbCore::q(string $sql, boolean $use_cache)

Execute a query

Arguments

  • $sql string
  • $use_cache boolean

query

mixed DbCore::query(string $sql)

Execute a query and get result ressource

Arguments

  • $sql string

s

mixed DbCore::s($sql, $use_cache)

Arguments

  • $sql mixed
  • $use_cache mixed

set_db

mixed DbPDOCore::set_db($db_name)

Arguments

  • $db_name mixed

tryToConnect

mixed DbPDOCore::tryToConnect($server, $user, $pwd, $db, $newDbLink, $engine, $timeout)

Arguments

  • $server mixed
  • $user mixed
  • $pwd mixed
  • $db mixed
  • $newDbLink mixed
  • $engine mixed
  • $timeout mixed

tryUTF8

mixed DbPDOCore::tryUTF8($server, $user, $pwd)

Arguments

  • $server mixed
  • $user mixed
  • $pwd mixed

update

boolean DbCore::update(string $table, array $data, string $where, integer $limit, boolean $null_values, boolean $use_cache, boolean $add_prefix)

Arguments

  • $table string - Table name without prefix
  • $data array - Data to insert as associative array. If $data is a list of arrays, multiple insert will be done
  • $where string - WHERE condition
  • $limit integer
  • $null_values boolean - If we want to use NULL values instead of empty quotes
  • $use_cache boolean
  • $add_prefix boolean - Add or not DB_PREFIX before table name