B. Johannessen wrote:
Praneet Kandula wrote:
On 10/15/05, Lukas Kahwe Smith smith@pooteeweet.org wrote:
I just made the backend selectable and integrated the MDB2 backend ..
For this I moved the inclusion of the rcube_db.inc frm the index.php file into main.inc. I also added a new config option 'db_backend' to db.inc.php.
Wow, thanks a lot for this, Lukas. For those that don't know, Lukas Smith is a key member of the PEAR group, and the lead developer of MDB2, which is supposed to be the replacement for PEAR::DB. I hope we accept this patch in!
Actually I stepped down from the PEAR Group a while back. But I am still quite active in the PEAR project.
FYI: Lukas isn't on the list yet, so for now please keep him in the To:/Cc: on any replies concerning MDB2.
I just subscribed.
Anyways I noticed that you have structured the code in a way that I personally consider one of my pet peeves. Here is how I have structured the directory layout for my framework: http://oss.backendmedia.com/WebBuilder2/DirectoryTree
Notice that inside the public html dir there are only files which users are allowed to read and none of the includes or config files. This is a much safer layout that is much less likely to cause security issues due to minor config issues.
regards, Lukas
Lukas Kahwe Smith wrote:
B. Johannessen wrote:
Praneet Kandula wrote:
On 10/15/05, Lukas Kahwe Smith smith@pooteeweet.org wrote:
I just made the backend selectable and integrated the MDB2 backend ..
For this I moved the inclusion of the rcube_db.inc frm the index.php file into main.inc. I also added a new config option 'db_backend' to db.inc.php.
Wow, thanks a lot for this, Lukas. For those that don't know, Lukas Smith is a key member of the PEAR group, and the lead developer of MDB2, which is supposed to be the replacement for PEAR::DB. I hope we accept this patch in!
Actually I stepped down from the PEAR Group a while back. But I am still quite active in the PEAR project.
FYI: Lukas isn't on the list yet, so for now please keep him in the To:/Cc: on any replies concerning MDB2.
One more thing on the DB/MDB2 integration .. you can actually easily make your application self installing. You would simply need to add to the code to expect the relevant error code and you could then execute the installation of the tables (and in theory even database) on the fly.
Have a look at the MDB2 implementation of the nextID() method in the mysql driver: http://cvs.php.net/co.php/pear/MDB2/MDB2/Driver/mysql.php#625
With the following code you silence the global error handling for the given error code: $this->expectError(MDB2_ERROR_NOSUCHTABLE);
This however only works if you extend from the PEAR class. But there is also a static equivalent method, more details can be found here: http://phpmag.net/itr/online_artikel/psecom,id,330,nodeid,114.html
The important bit is simply that there is an error code you can then check for and then issue the necessary SQL commands. Either from a file or using the MDB2 manager API.
regards, Lukas
Hi !!
I just made the backend selectable and integrated the MDB2 backend ..
as it looks like MDB2 can get rid of almost all problems with different syntax in mysql/postgres/sqlite, maybe MDB2 is the way to go. Also it would be better to put all sql queries appart from the main code, making classes that encapsulate all the db handling (add/delete/count/query)
Since in theory I need to do real work I am very motivated to do all sorts of other work ;-)
So I just created a new module for MDB2 .. this one abstracts the various differences in SQL function names .. so in order to get it to work you need install MDB2 CVS, call loadModule('Function') in the MDB2 driver instance and then:
replace NOW() with ".$DB->db_handle->function->now()." in all your SQL commands ..
regards, Lukas
Hi,
Thanks Lukas to post your implementation of the MDB2 package to RoundCube. to be honest, I did not care about database abstraction when I started this project but I know understand how important this is. Fortunately, RoundCube does not include heavy SQL queries and it could be easy to to change all calls to the DB wrapper in order to have the database abstraction complete.
David, do you have time to have a look at this topic? I think we could completely replace the existing rcube_db class and change all $DB->query calls to use MDB2 directly. Also we should use all abstraction methods available to compose the query.
I'm currently working on the IMAP caching problem and I think we should change the DB access of RoundCube now in order to have a solid code base for future development.
What you think? anybody has time to clean the RoundCube code?
Thanks! Thomas
2005/10/16, David Saez Padros david@ols.es:
Hi !!
I just made the backend selectable and integrated the MDB2 backend .
as it looks like MDB2 can get rid of almost all problems with different syntax in mysql/postgres/sqlite, maybe MDB2 is the way to go. Also it would be better to put all sql queries appart from the main code, making classes that encapsulate all the db handling (add/delete/count/query)
-- Best regards ...
David Saez Padros http://www.ols.es On-Line Services 2000 S.L. e-mail david@ols.es Pintor Vayreda 1 telf +34 902 50 29 75 08184 Palau-Solita i Plegamans movil +34 670 35 27 53
Hi !!
David, do you have time to have a look at this topic? I think we could completely replace the existing rcube_db class and change all $DB->query calls to use MDB2 directly. Also we should use all abstraction methods available to compose the query.
ok, i could do that, will try to have it ready this week.
David Saez Padros wrote:
David, do you have time to have a look at this topic? I think we could completely replace the existing rcube_db class and change all $DB->query calls to use MDB2 directly. Also we should use all abstraction methods available to compose the query.
ok, i could do that, will try to have it ready this week.
If you guys do end up going with MDB2 I can answer questions until tuesday evening. On wednesday morning till wednesday evening the following week I will be offline .. playing frisbee on the beaches of Mallorca :-)
Regarding the abstraction of NOW() this blog post will be of interest: http://pooteeweet.org/blog/251
I am very willing to add even more functions like the unix timestamp function stuff you guys are also using.
regards, Lukas