[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/_core/model/db/ -> _db.class.php (sommaire)

This file implements the DB class. Based on ezSQL - Class to make it very easy to deal with MySQL database connections. b2evo Additions: - nested transactions - symbolic table names - query log - get_list - dynamic extension loading - Debug features (EXPLAIN...) and more...

Author: blueyed: Daniel HAHLER
Author: fplanque: Francois PLANQUE
Author: Justin VINCENT
Copyright: (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}.
Version: $Id: _db.class.php,v 1.2 2007/10/01 19:02:23 fplanque Exp $
Poids: 1525 lignes (42 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

DB:: (22 méthodes):
  DB()
  select()
  escape()
  quote()
  null()
  week()
  print_error()
  flush()
  get_version()
  query()
  get_var()
  get_row()
  get_col()
  get_assoc()
  get_results()
  debug_get_rows_table()
  format_query()
  dump_queries()
  begin()
  commit()
  rollback()
  set_connection_charset()

Définit 22 fonctions

  mysql_real_escape_string()

Classe: DB  - X-Ref

The Main Class

DB( $params )   X-Ref
DB Constructor

Connects to the server and selects a database.

param: array An array of parameters.

select($db)   X-Ref
Select a DB (if another one needs to be selected)


escape($str)   X-Ref
Format a string correctly for safe insert under all PHP conditions


quote($str)   X-Ref
Quote a value, either in single quotes (and escaped) or if it's NULL as 'NULL'.

return: string Quoted (and escaped) value or 'NULL'.

null($val)   X-Ref

return: string Return the given value or 'NULL', if it's === NULL.

week( $date, $startofweek )   X-Ref
Returns the correct WEEK() function to get the week number for the given date.

param: string will be used as is
param: integer 0 for sunday, 1 for monday

print_error( $title = '', $html_str = '', $query_title = '' )   X-Ref
Print SQL/DB error.

TODO: fp> bloated: it probably doesn't make sense to display errors if we don't stop. Any use case?
dh> Sure. Local testing (and test cases).

param: string Short error (no HTML)
param: string Extended description/help for the error (for HTML)
param: string|false Query title; false if {@link DB::$last_query} should not get displayed

flush()   X-Ref
Kill cached query results


get_version()   X-Ref
Get MYSQL version


query( $query, $title = '' )   X-Ref
Basic Query

param: string SQL query
param: string title for debugging
return: mixed # of rows affected or false if error

get_var( $query = NULL, $x = 0, $y = 0, $title = '' )   X-Ref
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 {@link $num_rows}.

return: mixed NULL if not found, the value otherwise (which may also be NULL).

get_row( $query = NULL, $output = OBJECT, $y = 0, $title = '' )   X-Ref
Get one row from the DB - see docs for more detail

return: array|object

get_col( $query = NULL, $x = 0, $title = '' )   X-Ref
Function to get 1 column from the cached result set based in X index
see docs for usage and info

return: array

get_assoc( $query = NULL, $title = '' )   X-Ref
Function to get the second column from the cached result indexed by the first column

return: array [col_0] => col_1

get_results( $query = NULL, $output = OBJECT, $title = '' )   X-Ref
Return the the query as a result set - see docs for more details

return: array

debug_get_rows_table( $max_lines, $break_at_comma = false )   X-Ref
Get a table (or "<p>No Results.</p>") for the SELECT query results.

return: string HTML table or "No Results" if the

format_query( $sql, $html = true )   X-Ref
Format a SQL query

param: string SQL
param: boolean Format with/for HTML?

dump_queries()   X-Ref
Displays all queries that have been executed


begin()   X-Ref
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
{@link DB::commit() COMMIT} or a {@link DB:rollback() 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.

commit()   X-Ref
Commit current transaction


rollback()   X-Ref
Rollback current transaction


set_connection_charset( $charset, $use_map = false )   X-Ref
Set the charset of the connection.

WARNING: this will fail on MySQL 3.23

param: string Charset
param: boolean Use the "regular charset => mysql charset map"?
return: boolean true on success, false on failure

Fonctions
Fonctions qui ne font pas partie d'une Classe:



Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics