PHP 클래스 Pommo_Db, poMMo

파일 보기 프로젝트 열기: soonick/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