PHP Class Pommo_Db, poMMo

Afficher le fichier Open project: soonick/poMMo

Méthodes publiques

Свойство Type Description
$_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

Méthodes publiques

Méthode Description
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.

Method Details

Pommo_Db() public méthode

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

affected() public méthode

result.
public affected ( $sql = NULL )

close() public méthode

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

debug() public méthode

public debug ( $val )

dieOnQuery() public méthode

public dieOnQuery ( $val )

getAll() public méthode

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

getError() public méthode

public getError ( )

getRows() public méthode

* 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() public méthode

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

prepare() public méthode

throwing a warning)
public prepare ( )

query() public méthode

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() public méthode

saved result.
public records ( $sql = NULL )

Property Details

$_database public_oe property

public $_database

$_debug public_oe property

public $_debug

$_dieOnQuery public_oe property

public $_dieOnQuery

$_prefix public_oe property

name of database
public $_prefix

$_result public_oe property

public $_result

$_results public_oe property

& not overwriting the loops conditional resultset)
public $_results

$_safeSQL public_oe property

public $_safeSQL

$table public_oe property

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