Class db_mysql

Description

Classe for communicate with the database

Gets data from database with utf8 connenction. Class is modified from the german book: Michael Kofler and Bernd Öggl: PHP 5 & MySQL 5 - Grundlagen, Programmiertechniken, Beispiele. Addison-Wesley. 2006

  • author: Andreas Plank <andreas.plank@web.de>
  • version: 2009-02-24 21:24:33
  • copyright: Creative Commons Noncommercial 3.0

Located in /structure/classes/sql.php (line 25)


	
			
Variable Summary
 mixed $dbtime
 mixed $doReturn
 mixed $mysqli
 mixed $rowcounter
 mixed $showerror
 mixed $showsql
 mixed $sqlcounter
 mixed $starttime
Method Summary
 db_mysql __construct ()
 void __destruct ()
 FALSE close ()
 see error ()
 mixed escape ( $txt)
 boolean execute ($sql $sql)
 void getMysqli ()
 void insertId ()
 array|FALSE queryArray ($sql $sql)
 objArray|FALSE queryObjectArray ($sql $sql)
 string|-1|FALSE querySingleItem ($sql $sql)
 HTML resetStatistics ()
 HTML showStatistics ([ $doReturn = false])
 string sql_string (string $txt)
Variables
mixed $dbtime = 0 (line 31)
  • access: protected
mixed $doReturn = FALSE (line 33)
  • access: public
mixed $mysqli (line 26)
  • access: protected
mixed $rowcounter = 0 (line 30)
  • access: protected
mixed $showerror = TRUE (line 27)
  • access: protected
mixed $showsql = FALSE (line 28)
  • access: public
mixed $sqlcounter = 0 (line 29)
  • access: protected
mixed $starttime (line 32)
  • access: protected
Methods
Constructor __construct (line 41)

Prepare MySQL database connenction

Reads configuration settings and establishes an utf8 connenction. Provides time summarization. Works with PHP class mysqli.

db_mysql __construct ()
Destructor __destruct (line 67)

close database connenction

void __destruct ()
close (line 75)

explicit close

FALSE close ()
error (line 238)

Returns errors

  • return: mysqli
see error ()
escape (line 216)

Inserts a \ before ', " etc.

mixed escape ( $txt)
  • $txt
execute (line 186)

Execute a SQL command no *results* returned

boolean execute ($sql $sql)
  • $sql $sql: an SQL string
getMysqli (line 84)

Returns $mysqli

void getMysqli ()
insertId (line 208)

Get inserted ID after INSERT

void insertId ()
queryArray (line 123)

Execute SELECT query

array|FALSE queryArray ($sql $sql)
  • $sql $sql: an SQL string
queryObjectArray (line 95)

Execute SELECT query

This returns an class object. You can get results with

  1. $objMyDatabase->columnName

objArray|FALSE queryObjectArray ($sql $sql)
  • $sql $sql: an SQL string
querySingleItem (line 156)

Return a single item

Only a single item, e.g.:

  1. SELECT COUNT(*FROM table;
Attention: this method returns -1 for no data and false for an error.

string|-1|FALSE querySingleItem ($sql $sql)
  • $sql $sql: an SQL string
resetStatistics (line 316)

Set statistics to zero

HTML resetStatistics ()
showStatistics (line 298)

Print statistics

Output is given as CSS class 'info':

  1. <div class='info'>...</div>

HTML showStatistics ([ $doReturn = false])
  • $doReturn
sql_string (line 227)

Escapes strings for save

string sql_string (string $txt)
  • string $txt: text that will be escaped: 'NULL' if empty or 'quoted \'Strings\''

Documentation generated on Sun, 19 Jul 2009 14:48:44 +0800 by phpDocumentor 1.4.2