Loading

Database Abstraction

General Discussion around Collabtive

Database Abstraction

Postby DrDeth » 13.03.2009, 22:10

I've started extending the database abstraction of Collabtive for my own use - basically implementing the datenbank class - to allow the use of other databases like PostgreSQL. The DB can be set on the install page and is saved in the config. Any of the methods in the datenbank class can check the DB type to call the correct PHP functions. I've moved the table creation from the install script to their own scripts, called by DB type, so that table creation SQL can be rewritten per type.

Now, I've started on the rest of the classes to modify them to use the new datenbank class. This is a long process of replacing the mysql calls to use the class. So far my changes are working to get Collabtive installed on PostgreSQL - though I've had to change some of the column names so these will have to be reworked into the mysql scripts.

I still have a way to go, but I thought I'd let you know what I was up to if you'd like to take a look when I'm done (for inclusion in Collabtive release).

Thanks for a great app.
;)
DrDeth
 
Posts: 5
Joined: 13.03.2009, 21:40

Re: Database Abstraction

Postby DrDeth » 19.03.2009, 15:47

An update:
This is no trivial task. Besides what I have already mentioned, most of the current SQL has had to be modified to work on Postgres. Most of my modifications have moved the SQL to a more ANSI SQL compliant state, though I'm not sure what mysql would do with it. As it is, the original table creation scripts for mysql will need to be modified to work with new column names - which were the same as SQL reserved words (user & desc).

I have also had to modify the code and templates anywhere that the ID column is referenced. The reason for this is because column names in Postgres are not case sensitive by default, so all column names are returned as lower case, which means that PHP cant find $row['ID'], and the templates cant find $project.ID. While this may seem like 'the hard way', rather than just changing my DB to be case sensitive, I wanted to keep in mind for future that any number of databases could be supported - DB2, Oracle, MSSQL by just amending the datenbank class and table creation.

The fun will start when Collabtive 0.5 is released and I have to merge the new additions which my modifications. :cry:
DrDeth
 
Posts: 5
Joined: 13.03.2009, 21:40

Re: Database Abstraction

Postby Philipp » 19.03.2009, 15:56

What about contributing your changes to us, so we'd have a chance to merge them into /trunk ?
This would make it easier to have working postgres support in releases going forward.

I understand that making SQL queries more ANSI compatible (using AND instead of HAVING, etc) will help compatibility.
Help in doing this is greatly appreciated.

I'm quite interested in supporting other databases, and am willing to make some structural changes to Collabtive to support this, as needed.
However, i never wanted to use some of the "fat" DB abstraction layers like PEAR::DB , cause they tend to impede performance.
Some perspective on this: http://jeremy.zawodny.com/blog/archives/002194.html
User avatar
Philipp
Site Admin
 
Posts: 1118
Joined: 14.12.2007, 03:06
Location: Saarbrücken, germany

Re: Database Abstraction

Postby DrDeth » 20.03.2009, 18:09

Hi Phillip,

You can definitely take a look at my changes, though I'm not sure how well they would merge back into /trunk. I've implemented the datenbank class and modified just about every page/file to get it working.

You can grab a copy from here:
http://cid-5ae2843e2fdc37d3.skydrive.live.com/browse.aspx/Public/Collabtive

I've done a quick run through each page and eliminated any errors that appeared in the server logs, but I havent given it a thorough test yet.
DrDeth
 
Posts: 5
Joined: 13.03.2009, 21:40

Re: Database Abstraction

Postby heo_s.jacky » 14.01.2010, 15:59

What happened to this issue? Is it by any chance implemented by now?
"We're not your classic heroes, we're the other guys."
"Fail, learn, fail better"

Collabtive [0.6.2]
Win2000 prof.
Apache/2.2.14 (Win32)
mySQL 5.1.41
PHP/5.3.1
User avatar
heo_s.jacky
 
Posts: 6
Joined: 12.01.2010, 13:32

Re: Database Abstraction

Postby Philipp » 15.02.2013, 06:53

Collabtive 1.0 will use PDO. This should make this much much easier since PDO abstracts away connecting and querying databases.
(It does not rewrite queries, though)

See https://github.com/philippK-de/Collabtive
User avatar
Philipp
Site Admin
 
Posts: 1118
Joined: 14.12.2007, 03:06
Location: Saarbrücken, germany


Return to General

Who is online

Users browsing this forum: No registered users

cron