PHP 클래스 DBmysql, glpi

파일 보기 프로젝트 열기: glpi-project/glpi 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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