b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Class: DB

Source Location: /blogs/b2evocore/_class_db.php

Class DB

Property Summary
mixed   $col_info  
mixed   $dbaliases   Aliases that will be replaced in queries:
mixed   $dbreplaces   Strings that will replace the aliases in queries:
mixed   $dbtableoptions   CREATE TABLE options.
mixed   $debug_dump_rows   Number of rows we want to dump in debug output:
mixed   $debug_explain_joins   Do we want to explain joins?
mixed   $error  
mixed   $halt_on_error  
mixed   $insert_id  
mixed   $last_error  
mixed   $last_query  
mixed   $last_result  
mixed   $num_queries  
mixed   $num_rows  
mixed   $queries   Log of queries:
mixed   $rollback_nested_transaction   Rememeber if we have to rollback at the end of a nested transaction construct
mixed   $rows_affected  
mixed   $show_errors  
mixed   $transaction_nesting_level   How many transactions are currently nested?
mixed   $use_transactions   Do we want to use transactions:
mixed   $vardump_called  

[ Top ]
Method Summary
DB   DB()   DB Constructor
void   begin()   BEGIN A TRANSCATION
void   commit()   Commit current transaction
string   compString()   Returns the appropriate string to compare $val in a WHERE clause.
void   debug_dump_rows()   Displays the last query string that was sent to the database & a table listing results (if there were any).
void   dumpvar()   Alias for vardump()
void   dump_queries()   Displays all queries that have been exectuted
void   escape()   Format a string correctly for safe insert under all PHP conditions
void   flush()   Kill cached query results
array   get_col()   Function to get 1 column from the cached result set based in X index see docs for usage and info
void   get_col_info()   Function to get column meta data info pertaining to the last query
string   get_list()   Get a column as comma-seperated list.
array   get_results()   Return the the query as a result set - see docs for more details
array|object   get_row()   Get one row from the DB - see docs for more detail
mixed   get_var()   Get one variable from the DB - see docs for more detail
void   null()  
void   print_error()   Print SQL/DB error.
mixed   query()   Basic Query
void   quote()  
void   rollback()  
void   select()   Select a DB (if another one needs to be selected)
void   vardump()   Dumps the contents of any input variable to screen in a nicely formatted and easy to understand way - any type: Object, Var or Array
void   week()   Returns the correct WEEK() function to get the week number for the given date.

[ Top ]
Properties
mixed   $col_info [line 112]

[ Top ]
mixed   $dbaliases = array() [line 126]

Aliases that will be replaced in queries:


[ Top ]
mixed   $dbreplaces = array() [line 130]

Strings that will replace the aliases in queries:


[ Top ]
mixed   $dbtableoptions [line 135]

CREATE TABLE options.


[ Top ]
mixed   $debug_dump_rows = 0 [line 104]

Number of rows we want to dump in debug output:


[ Top ]
mixed   $debug_explain_joins = false [line 99]

Do we want to explain joins?


[ Top ]
mixed   $error = false [line 108]

[ Top ]
mixed   $halt_on_error = true [line 107]

[ Top ]
mixed   $insert_id = 0 [line 115]

[ Top ]
mixed   $last_error = '' [line 111]

[ Top ]
mixed   $last_query = '' [line 110]

[ Top ]
mixed   $last_result [line 118]

[ Top ]
mixed   $num_queries = 0 [line 109]

[ Top ]
mixed   $num_rows = 0 [line 116]

[ Top ]
mixed   $queries = array() [line 122]

Log of queries:


[ Top ]
mixed   $rollback_nested_transaction = false [line 150]

Rememeber if we have to rollback at the end of a nested transaction construct


[ Top ]
mixed   $rows_affected = 0 [line 117]

[ Top ]
mixed   $show_errors = true [line 106]

[ Top ]
mixed   $transaction_nesting_level = 0 [line 145]

How many transactions are currently nested?


[ Top ]
mixed   $use_transactions [line 140]

Do we want to use transactions:


[ Top ]
mixed   $vardump_called [line 114]

[ Top ]
Methods
Constructor DB  [line 160]

  DB DB( $dbuser, $dbpassword, $dbname, $dbhost, $dbaliases, [ $halt_on_error = true], [ $db_use_transactions = false], [ $dbtableoptions = '']  )

DB Constructor

connects to the server and selects a database

blueyed> Note: Too many parameters (and without default). Should be accessed through members. $halt_on_error is relevant to the connect procedure and should be put after $dbhost.

Parameters:
   $dbuser: 
   $dbpassword: 
   $dbname: 
   $dbhost: 
   $dbaliases: 
   $halt_on_error: 
   $db_use_transactions: 
   $dbtableoptions: 


[ Top ]
begin  [line 952]

  void begin( )

BEGIN A TRANSCATION

Note: By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a statement that updates (modifies) a table, MySQL stores the update on disk. Once you execute a BEGIN, the updates are "pending" until you execute a COMMIT {@see DB::commit()} or a ROLLBACK {@see DB:rollback()}

Note 2: standard syntax would be START TRANSACTION but it's not supported by older MySQL versions whereas BEGIN is...

Note 3: The default isolation level is REPEATABLE READ.



[ Top ]
commit  [line 966]

  void commit( )

Commit current transaction



[ Top ]
compString  [line 285]

  string compString( mixed $val  )

Returns the appropriate string to compare $val in a WHERE clause.

Parameters:
mixed   $val:  Value to create a "compare-String" for

API Tags:
Return:  Either 'IS NULL', 'IN ("a", "b", "c")' or " = 'a'".


[ Top ]
debug_dump_rows  [line 802]

  void debug_dump_rows( $max_lines, [ $break_at_comma = false]  )

Displays the last query string that was sent to the database & a table listing results (if there were any).

(abstracted into a seperate file to save server overhead).

Parameters:
   $max_lines: 
   $break_at_comma: 


[ Top ]
dumpvar  [line 791]

  void dumpvar( mixed $mixed  )

Alias for vardump()

Parameters:
mixed   $mixed:  Variable to dump


[ Top ]
dump_queries  [line 890]

  void dump_queries( )

Displays all queries that have been exectuted



[ Top ]
escape  [line 235]

  void escape( $str  )

Format a string correctly for safe insert under all PHP conditions

Parameters:
   $str: 


[ Top ]
flush  [line 382]

  void flush( )

Kill cached query results



[ Top ]
get_col  [line 647]

  array get_col( [ $query = NULL], [ $x = 0], [ $title = '']  )

Function to get 1 column from the cached result set based in X index see docs for usage and info

Parameters:
   $query: 
   $x: 
   $title: 


[ Top ]
get_col_info  [line 734]

  void get_col_info( [ $info_type = 'name'], [ $col_offset = -1]  )

Function to get column meta data info pertaining to the last query

see docs for more info and usage

Parameters:
   $info_type: 
   $col_offset: 


[ Top ]
get_list  [line 673]

  string get_list( [string|NULL $query = NULL], [integer $x = 0], [ $title = '']  )

Get a column as comma-seperated list.

Parameters:
string|NULL   $query:  Query to execute
integer   $x:  Column of the result set
   $title: 


[ Top ]
get_results  [line 684]

  array get_results( [ $query = NULL], [ $output = OBJECT], [ $title = '']  )

Return the the query as a result set - see docs for more details

Parameters:
   $query: 
   $output: 
   $title: 


[ Top ]
get_row  [line 600]

  array|object get_row( [ $query = NULL], [ $output = OBJECT], [ $y = 0], [ $title = '']  )

Get one row from the DB - see docs for more detail

Parameters:
   $query: 
   $output: 
   $y: 
   $title: 


[ Top ]
get_var  [line 569]

  mixed get_var( [ $query = NULL], [ $x = 0], [ $y = 0], [ $title = '']  )

Get one variable from the DB - see docs for more detail

Note: To be sure that you received NULL from the DB and not "no rows" check for $num_rows.

Parameters:
   $query: 
   $x: 
   $y: 
   $title: 

API Tags:
Return:  NULL if not found, the value otherwise (which may also be NULL).


[ Top ]
null  [line 250]

  void null( $val  )

Parameters:
   $val: 


[ Top ]
print_error  [line 305]

  void print_error( [ $str = ''], [ $query_title = '']  )

Print SQL/DB error.

Parameters:
   $str: 
   $query_title: 


[ Top ]
query  [line 401]

  mixed query( string $query, [string $title = '']  )

Basic Query

Parameters:
string   $query:  SQL query
string   $title:  title for debugging

API Tags:
Return:  # of rows affected or false if error


[ Top ]
quote  [line 241]

  void quote( $str  )

Parameters:
   $str: 


[ Top ]
rollback  [line 990]

  void rollback( )


Information Tags:
Todo:  implement transactions!

[ Top ]
select  [line 219]

  void select( $db  )

Select a DB (if another one needs to be selected)

Parameters:
   $db: 


[ Top ]
vardump  [line 762]

  void vardump( [mixed $mixed = '']  )

Dumps the contents of any input variable to screen in a nicely formatted and easy to understand way - any type: Object, Var or Array

Parameters:
mixed   $mixed:  Variable to dump


[ Top ]
week  [line 268]

  void week( string $date, integer $startofweek  )

Returns the correct WEEK() function to get the week number for the given date.

{@see http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html}

Parameters:
string   $date:  will be used as is
integer   $startofweek:  0 for sunday, 1 for monday

Information Tags:
Todo:  disable when MySQL < 4

[ Top ]

Documentation generated on Tue, 20 May 2008 01:52:58 +0200 by phpDocumentor 1.4.2