On top of that, I wasn't wild about the Zeos API either. I'm familiar with the PHP way of doing things, especially with the new PHP Data Objects class released with PHP 5.1.1.
So using Zeos 6.5.1 as a basis, I built a PDO wrapper for Delphi and I intend that it also works with Free Pascal. I completely reworked the 4.1 driver and added a 5.0 driver. I stripped out all the emulated statements. The drivers are 100% native and the interface is very nearly identical to the PHP's PDO interface.
Besides working natively, this means you can truly bind columns to variables as well as binding values. It works with the native "?" markers and also implements PHP's ":variable" named placemarkers. You can execute and bind at the same time, e.g. stmt.execute('3|joe smith|failed'). Due to pascal language constraints, I couldn't exactly mimic that part of the PDO class, but this alternative is also useful.
I also added a little something of my own -- for select statements, you can supply it in 6 parts and the class will assemble the statement in the SQL dialect of the driver being used, including Mysql/postgreSQL/SQLite , ODBC/DB2 , MSSQL/Sybase , Oracle, and interbase/firebird. The idea is you write the select SQL once and can switch database backends without worrying about native sql variances. This function doesn't really support subqueries, but you can always put in regular SQL statements, this is just an option.
In the end, there is not much Zeos left. I stripped most of it out. About the only recognizably bits are the plaindriver files and some odds and ends. Here's the reason why I'm posting this: If there is a great deal of interest of having working native MySQL 4.1 and 5.0 drivers, I will release the code. If that happens, there are some things you need to know:
- Mysql 3.20 and 3.23 were dropped
- Mysql 4.0 works, but not for any of the prepared statement code. A message box pops up with a "this function not supported" if you attempt to do so.
- It's interface-coded such that other drivers can be added
- I developed this for a reason, I need it, and I have no time to develop it further beyond my own needs.
- I do have time to maintain it though - if someone gives me code fixes/drivers, I'll add to the repository
- It would be stored on a public Subversion repository
- I could set up a little wiki with the basics
- The object of this PDO class is not span all protocols of all database, so emulated transactions / prep statements aren't supported
- Despite setting the ground work for db-independence, it's not my goal to build native drivers for all these.
- Left to my own devices, I might get around to building drivers for SQLite 3 and PostgreSQL 8.1, but that will be on the order of a year or more from now.
- Getting this to work with Free Pascal / Lazarus is a top priority for me. It may work now, but it needs testing. I will do that, because I need it.
- Having it work pre-Delphi 7: It might now, but I can't test it, and I won't go out of my way to make it happen.
- There's no visual component, it's just regular unit files
- I'm neither a delphi nor a database coding expert, but apparently I know enough of both to be dangerous.
- I have no intention on rolling these back into zeoslib - the driver files themselves are still compatible (at least with very little modification) so somebody else can use those to update zeos if they wish.
Zeos was the closest thing to what I needed, and the code helped me learn enough to be able to write my own wrapper/drivers. I believe the LGPL obligates me to provide the source of my modifications when my application is released, so this is an attempt to fulfill that obligation. It seemed like Zeos development has slowed or stopped, but in either case, I couldn't wait. My best motivation for doing this is having a lot of users/eyes on the code so any bugs get found/fixed and maybe some others can provide drivers I may need later. I'm testing the water, so if no one cares, just forget I said anything.
John