PHP Класс DBmysql, glpi

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$connected Is connected to the DB ?
$dbdefault ! Default Database
$dbh ! Database Handler
$dbhost ! Database Host - string or Array of string (round robin)
$dbpassword ! Database Password
$dbuser ! Database User
$error ! Database Error
$first_connection Is it a first connection ? Indicates if the first connection attempt is successful or not if first attempt fail -> display a warning which indicates that glpi is in readonly
$slave Slave management

Открытые методы

Метод Описание
__construct ( $choice = NULL ) : nothing Constructor / Connect to the MySQL Database
affected_rows ( ) : number Get number of affected rows in previous MySQL operation
checkForCrashedTables ( ) : an Check for crashed MySQL Tables
close ( ) : TRUE Close MySQL connection
connect ( $choice = NULL ) : nothing Connect using current database settings
data_seek ( $result, $num ) : boolean Move current pointer of a Mysql result to the specific row
errno ( ) : error Returns the numerical value of the error message from previous MySQL operation
error ( ) : error Returns the text of the error message from previous MySQL operation
escape ( $string ) : String Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
fetch_array ( $result ) : result Fetch array of the next row of a Mysql query Please prefer fetch_row or fetch_assoc
fetch_assoc ( $result ) : result Fetch assoc of the next row of a Mysql query
fetch_row ( $result ) : result Fetch row of the next row of a Mysql query
field_flags ( $result, $field ) : flags Get flags of a field of a mysql result
field_name ( $result, $nb ) : name Give name of a field of a Mysql result
free_result ( $result ) : Returns Free result memory
getInfo ( ) : Array Get information about DB connection for showSystemInformations
getLock ( $name ) : boolean Get a global DB lock
insert_id ( ) : item Give ID of the last insert item by Mysql
isMySQLStrictMode ( &$msg )
isSlave ( ) : boolean is a slave database ?
list_fields ( $table, $usecache = true ) : list List fields of a table
list_tables ( $table = "glpi_%" ) : list List tables in database
num_fields ( $result ) : number Give number of fields of a Mysql result
numrows ( $result ) : number Give number of rows of a Mysql result
optimize_tables ( $migration = NULL, $cron = false ) : number Optimize sql table
prepare ( $query ) : a Prepare a MySQL query
query ( $query ) : Query Execute a MySQL query
queryOrDie ( $query, $message = '' ) : Query Execute a MySQL query
releaseLock ( $name ) : boolean Release a global DB lock
request ( $tableorsql, $crit = "", $debug = false ) : DBIterator Instanciate a Simple DBIterator
result ( $result, $i, $field ) : Value Give result from a mysql result
runFile ( $path ) : boolean Execute all the request in a file

Описание методов

__construct() публичный Метод

try to connect
public __construct ( $choice = NULL ) : nothing
$choice integer, host number (default NULL)
Результат nothing

affected_rows() публичный Метод

Get number of affected rows in previous MySQL operation
public affected_rows ( ) : number
Результат number of affected rows on success, and -1 if the last query failed.

checkForCrashedTables() публичный статический Метод

Check for crashed MySQL Tables
public static checkForCrashedTables ( ) : an
Результат an array with supposed crashed table and check message

close() публичный Метод

Close MySQL connection
public close ( ) : TRUE
Результат TRUE on success or FALSE on failure.

connect() публичный Метод

Use dbhost, dbuser, dbpassword and dbdefault
public connect ( $choice = NULL ) : nothing
$choice integer, host number (default NULL)
Результат nothing

data_seek() публичный Метод

Move current pointer of a Mysql result to the specific row
public data_seek ( $result, $num ) : boolean
$result MySQL result handler
$num row to move current pointer
Результат boolean

errno() публичный Метод

Returns the numerical value of the error message from previous MySQL operation
public errno ( ) : error
Результат error number from the last MySQL function, or 0 (zero) if no error occurred.

error() публичный Метод

Returns the text of the error message from previous MySQL operation
public error ( ) : error
Результат error text from the last MySQL function, or '' (empty string) if no error occurred.

escape() публичный Метод

Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
public escape ( $string ) : String
$string String to escape
Результат String escaped

fetch_array() публичный Метод

Fetch array of the next row of a Mysql query Please prefer fetch_row or fetch_assoc
public fetch_array ( $result ) : result
$result MySQL result handler
Результат result array

fetch_assoc() публичный Метод

Fetch assoc of the next row of a Mysql query
public fetch_assoc ( $result ) : result
$result MySQL result handler
Результат result associative array

fetch_row() публичный Метод

Fetch row of the next row of a Mysql query
public fetch_row ( $result ) : result
$result MySQL result handler
Результат result row

field_flags() публичный Метод

Get flags of a field of a mysql result
public field_flags ( $result, $field ) : flags
$result MySQL result handler
$field field name
Результат flags of the field

field_name() публичный Метод

Give name of a field of a Mysql result
public field_name ( $result, $nb ) : name
$result MySQL result handler
$nb number of columns of the field
Результат name of the field

free_result() публичный Метод

Free result memory
public free_result ( $result ) : Returns
$result MySQL result handler
Результат Returns TRUE on success or FALSE on failure.

getInfo() публичный Метод

Get information about DB connection for showSystemInformations
public getInfo ( ) : Array
Результат Array of label / value

getLock() публичный Метод

Get a global DB lock
public getLock ( $name ) : boolean
$name String : name of the lock
Результат boolean

insert_id() публичный Метод

Give ID of the last insert item by Mysql
public insert_id ( ) : item
Результат item ID

isMySQLStrictMode() статический публичный Метод

static public isMySQLStrictMode ( &$msg )

isSlave() публичный Метод

is a slave database ?
public isSlave ( ) : boolean
Результат boolean

list_fields() публичный Метод

List fields of a table
public list_fields ( $table, $usecache = true ) : list
$table String table name condition
$usecache Boolean if use field list cache (default true)
Результат list of fields

list_tables() публичный Метод

List tables in database
public list_tables ( $table = "glpi_%" ) : list
$table table name condition (glpi_% as default to retrieve only glpi tables)
Результат list of tables

num_fields() публичный Метод

Give number of fields of a Mysql result
public num_fields ( $result ) : number
$result MySQL result handler
Результат number of fields

numrows() публичный Метод

Give number of rows of a Mysql result
public numrows ( $result ) : number
$result MySQL result handler
Результат number of rows

optimize_tables() статический публичный Метод

Optimize sql table
static public optimize_tables ( $migration = NULL, $cron = false ) : number
$migration migration class (default NULL)
$cron to know if optimize must be done (false by default)
Результат number of tables

prepare() публичный Метод

Prepare a MySQL query
public prepare ( $query ) : a
$query Query to prepare
Результат a statement object or FALSE if an error occurred.

query() публичный Метод

Execute a MySQL query
public query ( $query ) : Query
$query Query to execute
Результат Query result handler

queryOrDie() публичный Метод

Execute a MySQL query
public queryOrDie ( $query, $message = '' ) : Query
$query Query to execute
$message explaination of query (default '')
Результат Query result handler

releaseLock() публичный Метод

Release a global DB lock
public releaseLock ( $name ) : boolean
$name String : name of the lock
Результат boolean

request() публичный Метод

Examples = foreach ($DB->request("select * from glpi_states") as $data) { ... } foreach ($DB->request("glpi_states") as $ID => $data) { ... } foreach ($DB->request("glpi_states", "ID=1") as $ID => $data) { ... } foreach ($DB->request("glpi_states", "", "name") as $ID => $data) { ... } foreach ($DB->request("glpi_computers",array("name"=>"SBEI003W","entities_id"=>1),array("serial","otherserial")) { ... }
public request ( $tableorsql, $crit = "", $debug = false ) : DBIterator
$tableorsql table name, array of names or SQL query
$crit string or array of filed/values, ex array("id"=>1), if empty => all rows (default '')
$debug for log the request (default false) Examples = array("id"=>NULL) array("OR"=>array("id"=>1, "NOT"=>array("state"=>3))); array("AND"=>array("id"=>1, array("NOT"=>array("state"=>array(3,4,5),"toto"=>2)))) FIELDS name or array of field names ORDER name or array of field names LIMIT max of row to retrieve START first row to retrieve
Результат DBIterator

result() публичный Метод

Give result from a mysql result
public result ( $result, $i, $field ) : Value
$result MySQL result handler
$i Row to give
$field Field to give
Результат Value of the Row $i and the Field $field of the Mysql $result

runFile() публичный Метод

Execute all the request in a file
public runFile ( $path ) : boolean
$path string with file full path
Результат boolean true if all query are successfull

Описание свойств

$connected публичное свойство

Is connected to the DB ?
public $connected

$dbdefault публичное свойство

! Default Database
public $dbdefault

$dbh публичное свойство

! Database Handler
public $dbh

$dbhost публичное свойство

! Database Host - string or Array of string (round robin)
public $dbhost

$dbpassword публичное свойство

! Database Password
public $dbpassword

$dbuser публичное свойство

! Database User
public $dbuser

$error публичное свойство

! Database Error
public $error

$first_connection публичное свойство

Is it a first connection ? Indicates if the first connection attempt is successful or not if first attempt fail -> display a warning which indicates that glpi is in readonly
public $first_connection

$slave публичное свойство

Slave management
public $slave