Re: PEAR development

From: Date: Tue, 25 Feb 2003 10:09:21 +0000
Subject: Re: PEAR development
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13837@lists.php.net to get a copy of this message
On Tue, 25 Feb 2003 01:26:50 +0100 Pierre-Alain Joye <paj@pearfr.org> wrote: > On Mon, 24 Feb 2003 15:59:22 -0800 > Steven <runner@uclink4.berkeley.edu> wrote: > > > Hi, this question is concerning the addition of a particular php/mysql > > > > function. The function is mysql_insert_id(). As far as I can tell, > > PEAR does not offer any function that is compatible with this > > particular function. I'm wondering if there are any plans to add this > > to PEAR? Personally, I think this function is very useful and it > > would be a shame to not include it. > > I do not think there is be an addition for this function. This is a > mysql-mysql specific function, and, not portable, imho, even to avoid > its use (except in rare specific cases). > > You may try to look at sequences, which are available in PEAR::DB as > well as in PEAR::MDB, sequences do exactly the same and are safely > portable. However, trying to emulate sequences in databases who don´t support them natively isn´t really pretty as well. The following might be a solution for those who don´t want to use them: We´re using PEAR::DB for an application running on both MSSQL and MySQL, both support auto_increment fields. To get the most out of each database´s special features, we´ve put all SQL queries in separate classes: One "common" class, that contians all SQL queries that work in both DB´s, and one specific class for each DB, containing special SQL queries that use the specific features of each database. As we can also control the way of doing INSERT´s and getting new ID´s for each database this way, we can extend the existing database drivers to support the last_insert_id feature, doing something like this: class myMySQL extends DB_mysql { var $supportsLastInsertID = true; function getLastInsertID() { // do it } } When we do INSERTs, we simply check the $suppotsLastInsertID property - if true, we use the corresponding method, if not set, we use sequences. BUT: I agree that this functionality should not be integrated within the base DB package, because the way it is now encourages people to write more database-independent code ;-) Regards, Markus -- Markus Wolff <wolff@21st.de>

« previous php.pear.dev (#13837) next »