phpBB

Development Wiki

Talk:Database Abstraction Layer

From phpBB Development Wiki

Requested move

$dbDBAL — IMO this page should be named DBAL, "Database Access" or something like that because $db is just a variable name ~~~~ --Pyramide 01:39, 13 January 2007 (UTC)

  1. I agree with that... I'm going to create a template to use for page rename tagging.

P.S. When you create a new talk page, put {{TalkPage}} at the top. :)
Highway of Life (talk) 03:06, 13 January 2007 (UTC)

Explanation of Caching Architecture

Whilst some of the API arguments make a passing comment to caching, you really need to address this in this page or as a supplementary. The DB abstraction layer uses the cache class and the principle is that any SQL queries which are reasonably non-volatile and where result-set coherence is not essential should specify a time-to-live (ttl) parameter. This informs the db abstraction layer that the result of the query can be cached for ttl seconds. An example of where this is used is the count of guests visiting any given forum. This count is a snapshot that is only updated every 10 minutes... This plus discussion of the cache implementations (file, memcache, apc, xcache) would be very helpful for those trying to improve the efficiency of their installations. — Terrye 10:50, 28 May 2009 (UTC)

sql_in_set and DELETE

A very important function of the sql_in_set method was overlooked; It is used a lot for deleting data, we need an example and a some explanation. In addition that method isn't very well explained in general, it barley scratches the surface as to what this can do to your queries and how you structure them with this tool in dbal.

Will this work??

Example:
//Array with the data to insert
$data = array(
    
'username'     => 'Bertie',
    
'email'     => 'bertie@example.com',
);

// First doing a select with this data.
// Note: By using the SELECT type, it uses always AND in the query.
$sql 'SELECT user_password
    FROM ' 
USERS_TABLE '
    WHERE ' 
$db->sql_build_array('SELECT'$data);
$result $db->sql_query($sql);

// And doing an update query: (Using the same data as for SELECT)
$sql 'UPDATE ' USERS_TABLE ' SET ' $db->sql_build_array('UPDATE'$data);
$db->sql_query($sql);

// And as last, a insert query
$sql 'INSERT INTO ' USERS_TABLE ' ' $db->sql_build_array('INSERT'$data);
$db->sql_query($sql);

I'm talking about the UPDATE. Don't you need a WHERE statement? Maybe a slightly better example for an UPDATE Never mind. Its just a really bad SQL query