Al James
Newbie

Posts: 35
|
 |
« on: December 14, 2007, 06:04:12 PM » |
|
Hi there...
Returning to look at Kohana again after a spell in Zend land. I like whats going on here, I think you guys are making some good choices.
The only one I am questioning is the choice not to support PDO.
I read a post by one of the senior developers saying that the decision not to support PDO was well thought out, citing that "there is no point wrapping a wrapper". Well, there are two bits to the kohana DB layer:
* Database SQL access * Easy Query building API
Sure, PDO covers point 1 nicely, so there is an overlap between PDO and the kohana layer. So my question is: "Why not just use PDO for this?". Using native drivers means that someone has to write sql level access for all the major DBs.
Why not just write a query builder interface (active record in old CI speak) on top of PDO?
Sure there still might be some DB specific code (for non-standard SQL), but the code would be much, much smaller!
Anyway, whats everyones thoughts?
|
|
|
|
|
Logged
|
|
|
|
Shadowhand
Developer
Hero Member
    
Posts: 531
in yr loop!
|
 |
« Reply #1 on: December 14, 2007, 06:59:29 PM » |
|
You're free to write a PDO driver, and might merge it in as a module.
PDO has some nice features, but it's not PHP 5.1 compatible, and it's not proven to be (realistically) faster at anything except stored procedures.
|
|
|
|
« Last Edit: December 14, 2007, 07:22:52 PM by Woody Gilk »
|
Logged
|
|
|
|
|
zombor
|
 |
« Reply #2 on: December 14, 2007, 07:14:30 PM » |
|
Why not just write a query builder interface (active record in old CI speak) on top of PDO?
Because it would still have to go back to a database driver somewhere to get the query syntax. SQL syntax differs between all the major databases, and unless PDO can tell me how PGSQL needs it's insert statement, it's pointless to use it as a base for a Query Builder library. Since it has to go to the driver to find out what the syntax of a SELECT statement is, it makes sense to have that same driver actually execute the query using relatively low level calls. It basically all comes back to wrapping a wrapper.
|
|
|
|
« Last Edit: December 14, 2007, 07:16:45 PM by zombor »
|
Logged
|
|
|
|
Al James
Newbie

Posts: 35
|
 |
« Reply #3 on: December 15, 2007, 07:31:34 AM » |
|
PDO has some nice features, but it's not PHP 5.1 compatible, and it's not proven to be (realistically) faster at anything except stored procedures.
Umm, dont really understand this sentance. What makes you say PDO is not PHP 5.1 compatible? I use it everyday. Do you mean that PDO_MYSQL is not bundled by default? Sure. But if you use a decent package manager you will normally get it. Because it would still have to go back to a database driver somewhere to get the query syntax. SQL syntax differs between all the major databases, and unless PDO can tell me how PGSQL needs it's insert statement, it's pointless to use it as a base for a Query Builder library.
Sure, yes I realise that. But looking at the code in the existing mysql driver, most of it (by far) is concerned with mapping function calls onto the mysql_* functions and handling the resulting result set. Only a small portion is concerned with SQL writing. If the query builder was built on PDO it would leave only a very small SQL library for each DB (and, if was structured correctly, with all DB libraries inheriting from a standard SQL writer, these libraries would only be a few functions for each). It basically all comes back to wrapping a wrapper.
No, not at all. I comes back to not reinventing the wheel! Anyway. There is nothing wrong with wrapping a wrapper! Its the basis of extending classes in object oriented programming!
|
|
|
|
« Last Edit: December 15, 2007, 07:35:35 AM by Al James »
|
Logged
|
|
|
|
Dynom
Newbie

Posts: 41
Disturbed d-_-b
|
 |
« Reply #4 on: December 15, 2007, 07:52:42 PM » |
|
Your question is: "Why not just use PDO for this?" I wasn't there at the start, but I'd say compatibility and speed.
For speed: PDO is slower then the 'native' calls (e.g. mysql_*), so wrapping PDO is just an extra slowing factor. For compatibility: PDO is not everywhere available in the earlier PHP builds which Kohana want to support.
Kohana already has the library and right now it just needs to have more drivers.
|
|
|
|
|
Logged
|
It's never finished.
|
|
|
Al James
Newbie

Posts: 35
|
 |
« Reply #5 on: December 16, 2007, 06:00:17 AM » |
|
Your question is: "Why not just use PDO for this?" I wasn't there at the start, but I'd say compatibility and speed.
For speed: PDO is slower then the 'native' calls (e.g. mysql_*), so wrapping PDO is just an extra slowing factor.
Some people say its slower, some people say its faster. At the end of the day there is probably very little difference and you would never notice. For compatibility: PDO is not everywhere available in the earlier PHP builds which Kohana want to support.
From: http://doc.kohanaphp.com/installation/requirementsKohana requires PHP > 5.1.2. PDO is available on those builds. Kohana already has the library and right now it just needs to have more drivers.
Thats my point. Someones got to write all those drivers. PDO has them already (minus very light SQL layer for each non-standard SQL statement for each DB). One important goal of any open source project should be to write as little code as possible to achieve the end result. More code equals more manpower and more bugs.
|
|
|
|
|
Logged
|
|
|
|
|
PugFish
|
 |
« Reply #6 on: December 16, 2007, 07:25:27 AM » |
|
Kohana requires PHP > 5.1.2. PDO is available on those builds.
The problem is not PDO being available, it's the drivers being available. By default no drivers are enabled so it's up to the web host whether you can even use mysql.
|
|
|
|
|
Logged
|
|
|
|
Shadowhand
Developer
Hero Member
    
Posts: 531
in yr loop!
|
 |
« Reply #7 on: December 16, 2007, 12:41:48 PM » |
|
And the PDO drivers have consistently proven to have bugs and performance issues pre-v5.2.
|
|
|
|
|
Logged
|
|
|
|
allain
Newbie

Posts: 7
|
 |
« Reply #8 on: February 05, 2008, 10:23:51 PM » |
|
I have to agree with Al James.
I think writing our own database drivers is reinventing the wheel. Sure we limit the install base a little, but what host worth it's beans doesn't have the standard pdo database drivers installed.
|
|
|
|
|
Logged
|
|
|
|
Rick Jolly
Newbie

Posts: 45
|
 |
« Reply #9 on: February 06, 2008, 01:32:22 AM » |
|
Kohana 2.1 requires php 5.2 - one less argument against PDO.
|
|
|
|
|
Logged
|
|
|
|
|
PugFish
|
 |
« Reply #10 on: February 06, 2008, 02:15:45 AM » |
|
2.1 is still 5.1.2+, 2.2 will be 5.2
|
|
|
|
|
Logged
|
|
|
|
Dynom
Newbie

Posts: 41
Disturbed d-_-b
|
 |
« Reply #11 on: February 06, 2008, 04:14:20 AM » |
|
As long as PDO2 isn't finished yet, I think it's safe to say Kohana isn't going to use it.
|
|
|
|
|
Logged
|
It's never finished.
|
|
|
|
zombor
|
 |
« Reply #12 on: February 06, 2008, 10:16:26 AM » |
|
As long as PDO2 isn't finished yet, I think it's safe to say Kohana isn't going to use it. We have no intention of developing a database library that uses PDO, unless unforeseen circumstances change.
|
|
|
|
|
Logged
|
|
|
|
Rick Jolly
Newbie

Posts: 45
|
 |
« Reply #13 on: February 06, 2008, 04:28:18 PM » |
|
2.1 is still 5.1.2+, 2.2 will be 5.2
I guess I misinterpreted Woody's Kohana 2.1 Announcement: "The 2.1 release officially marks the end of PHP 5.1 support". So 2.1 is the last version supporting php 5.1. For those looking for an sql query builder working on PDO, the Zend_Db_Select is exactly that. A few benchmarks comparing Kohana's query builder and Zend's would help put a rest to this debate. If Zend's is faster, then Kohana has not only reinvented the wheel, the wheel has a lower performance rating. EDIT: I ran some totally quick and unscientific benchmarks... I benchmarked kohana and zend database performance using straight sql and query builders. I used the same queries and comparable query builder methods. I set both database libraries to return objects. I benchmarked the database loading and the queries seperately and together. Result: Kohana takes all. Kohana was over twice as fast and used less than half the memory when loading the database library, building select queries, and executing select queries. Kohana's database library doesn't have all the features or drivers of zend's, but it's light and fast. Well done. Man, what am I going to complain about now?
|
|
|
|
« Last Edit: February 07, 2008, 01:53:03 AM by Rick Jolly »
|
Logged
|
|
|
|
|