Peter Rehm's Blog

apple,development,life & more

ADODB Table Prefix

without Comments

Bei fast jedem Projekt arbeitet man mit Tabellen Prefixen, um das Projekt z.b. 2x in der gleichen Datenbank laufen zu lassen. Gestern habe ich angefangen mein Projekt auf ADOBD und dabei festgestellt dass es noch keine eingebaute Funktion für das Verwalten eines Prefixes gibt. Daher hab ich das nun auf meine Anforderungen angepasst.

Mein Prefix liegt in $cfg['tbl_prefix'].

Die Querys werden nun so aufgebaut ("SELECT * FROM ##daten").

Statt Execute nimmt man nun die neue Funktion pExecute.

Diese Funktion muss in die adodb.inc.php implementiert werden, ich hab diese in der aktuellen ADODB Version in Zeile 784 direkt vor Execute plaziert.

CODE:
/**
*    Function to Replace the Prefixes
*    After replacing it the SQL Statement will be passed to EXECUTE()
*    @param sql SQL statement to execute, ## will be replaced with the Prefix
*/
function &pExecute($sql)
{
global $cfg;
return $this->Execute(str_replace('##',$cfg['tbl_prefix'],$sql));
}

Posted by Peter Rehm

06/28/2006 at 10:39:27 AM

Posted in PHP, Programmierung

0 Trackbacks to ADODB Table Prefix

Trackback specific URI for this entry

  1. No Trackbacks

0 Comments to ADODB Table Prefix

  1. No comments

Add Comment

BBCode format allowed
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA