PHP Класс Pommo_Db, poMMo

Показать файл Открыть проект

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

Свойство Тип Описание
$_database
$_debug
$_dieOnQuery
$_link
$_prefix name of database
$_result
$_results & not overwriting the loops conditional resultset)
$_safeSQL
$table array of tables. array_key = nickname, value = table name in DB

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

Метод Описание
Pommo_Db ( $username = NULL, $password = NULL, $database = NULL, $hostname = NULL, $tablePrefix = NULL, $compress, $secure )
affected ( $sql = NULL ) result.
close ( ) closes the mySql link & frees the resources
debug ( $val )
dieOnQuery ( $val )
getAll ( $sql = NULL, $type = 'assoc', $field = NULL ) if field is given, just that field #/name is added to the array.
getError ( )
getRows ( $sql = NULL, $enumerated = FALSE, $uniqueId = NULL ) * useful for stuff like; while ($row = $dbo->getRows($sql)) $config[$row['config_name']] = $row['config_value'];
lastId ( $sql = NULL ) returns the ID of the pkey from an INSERT Statement FALSE if bad result
prepare ( ) throwing a warning)
query ( $query, $row = NULL, $col = NULL ) query function.
records ( $sql = NULL ) saved result.

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

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

public Pommo_Db ( $username = NULL, $password = NULL, $database = NULL, $hostname = NULL, $tablePrefix = NULL, $compress, $secure )

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

result.
public affected ( $sql = NULL )

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

closes the mySql link & frees the resources
public close ( )

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

public debug ( $val )

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

public dieOnQuery ( $val )

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

if field is given, just that field #/name is added to the array.
public getAll ( $sql = NULL, $type = 'assoc', $field = NULL )

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

public getError ( )

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

* useful for stuff like; while ($row = $dbo->getRows($sql)) $config[$row['config_name']] = $row['config_value'];
public getRows ( $sql = NULL, $enumerated = FALSE, $uniqueId = NULL )

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

returns the ID of the pkey from an INSERT Statement FALSE if bad result
public lastId ( $sql = NULL )

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

throwing a warning)
public prepare ( )

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

Returns true if the query was successful, or false if not*. * If $this->_dieOnQuery is set, a die() will be issued and the script halted. If _debug is set, the mysql_error will be appended to the die() call. _dieOnQuery is enabled by default. If query is called with numeric arguments, a specific field is returned. This is useful for SQL statements that return a single row, or multiple rows of a single column. ex. A] query($sql,3) -> returns 4th column of a resultset B] query($sql,0,2) -> returns the second column of the first row of a resultset. A is useful for a result set containing a single column, ie. "SELECT name FROM people"; Example invocations from partent script: $dbo = & Pommo::$_dbo; $dbo->dieOnQuery(TRUE); $dbo->debug(TRUE); $sql = "SOME SQL QUERY"; if ($DB->query($sql)) { while ($row = mysql_fetch_assoc($dbo->_result)) { echo $row[fieldname]; } } $dbo->dieOnQuery(FALSE); $firstname = $dbo->query(SELECT phone,name FROM users,0,2); if (!$firstname) { echo "INVALID QUERY"; } $numRowsInSet = $dbo->records() $numRecordsChanged = $dbo->affected() :: EXAMPLE OF ITERATING THROUGH A RESULT SET (ROWS) :: $sql = "SELECT name FROM users WHERE group='X'"; while ($row = $dbo->getRows($sql)) { $sql = "UPDATE name SET group='Y' WHERE config_name='".$row['name']."'"; if (!$dbo->query($sql)) die('Error updating group for '.$row['name']); } }
public query ( $query, $row = NULL, $col = NULL )

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

saved result.
public records ( $sql = NULL )

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

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

public $_database

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

public $_debug

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

public $_dieOnQuery

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

name of database
public $_prefix

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

public $_result

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

& not overwriting the loops conditional resultset)
public $_results

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

public $_safeSQL

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

array of tables. array_key = nickname, value = table name in DB
public $table