[GSoC-2013] Introduce PDO for MySQL

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.
Post Reply
hjpotter92
Registered User
Posts: 6
Joined: Mon Apr 08, 2013 10:15 pm

[GSoC-2013] Introduce PDO for MySQL

Post by hjpotter92 » Thu Apr 25, 2013 10:23 pm

I would like to implement the PDO methods to the current DBAL. Most likely, I'll create it from scratch as it'll help in the later stages of development and management. I am aware that this is a huge project and breaking it into parts which can be completed/tracked in the GSoC duration of 3 months is difficult.

Idea
My idea is an extension of existing RFC discussion here. As PDO is bundled with PHP itself, a lot of duplication in current DBAL used for phpBB can be reduced. Prepared statements provide a lot of flexibility too.

Benefits
  • PDO can be used to maintain FreeTDS/Microsoft SQL Server/Sybase, Firebird/Interbase 6, MySQL 3.x/4.x/5.x, PostgreSQL, SQLite 3 and SQLite 2, Microsoft SQL Server/SQL Azure and a lot of others(with active support for all of them).
  • Exceptions and error handling is easier; with the PDOExceptionclass.
  • Large objects(using PDO::PARAM_LOB) can also be stored and streamed to/from databases(such as avtars). I have not tried it myself though.
  • Cleaner code, with a lot of predefined methods. A simple extension of class is all that will be needed.
  • A database-specific PDO driver is needed to access a database server.
Current progress
I will be starting from scratch. A note can be taken into account of an unavailable repository from evil3 on the aforementioned RFC thread. A lot of progress and bugfixes have been done/released for PDO since the linked discussion on Area51 developments board. To name a few(which were also discussed/raised-as-flags in RFC thread) SSL support and buffered query support.

Project Summary and Timeline
Creating a new database abstraction layer extending PDO for MySQL. This will require/act-as a replacement of the current(too old, imo; but still working great) DBAL being used in releases of phpBB. Also, since it can be extended to support other drivers I'd be glad to stay with the phpBB community and keep developing it. My proposed timeline for this project shall be:
  • Get acquainted with current DBAL, read the mysql.php, mysql_base.php and mysqli.php present in the /includes/db/driver directory - 1 week.
  • Discuss the base methods required for new classes with mentor - 1 to 2 weeks. None or a minor programming done until now.
  • Write the classes pdo_driver, pdo_mysql following the coding guidelines but not necessarily supporting current DB calls in phpBB - 1 month. This patch is ready to be submitted for mid-term evaluation.
  • Collaborate work with mentor(s). Discuss necessary changes - 5 to 10 days.
  • Tweaking the current classes to facilitate working with the major phpBB development - 1 week.
  • Testing and modifying accordingly the finalized model with constant discussions on IRC and with mentor - 2 or 3 weeks.
  • Finalizing project. Minor cleaning up. Get the files ready for final submission - 3 to 5 days.
  • Further implement it for sqlite3 driver (after the GSoC period).
Personal
My name is Amritanshu Varshney. I'm a resident of India(GMT +5:30) and a student of Mathematics and Computing at Indian Institute of Technology, Kharagpur in Kharagpur, West Bengal. I can work on this project with dedication since I currently have no other project/work requiring my immediate attention(for at least two months). I can provide a net of 5 to 8 hours on a daily basis averaging to 35 hours for the weekdays(Monday through Friday). Also, on weekends my work time can increase up to 10 hours/day giving a total of at least 50 hours a week.

I have been working primarily with PHP for the past 2 years. I'm also an active user on Stack Overflow and keep regularly answering questions on PHP, MySQL, jQuery, HTML and other web-development languages. I have also been using phpBB and modifying it, mostly templates, in my leisure time. So far, I've only sent three pull requests one of which has been merged and two are still awaiting.

I'm quite familiar with PDO_MYSQL driver and hence, my primary aim during the project is just for developing MySQL. My work progress can be tracked easily on my GitHub account. I use the nickname hjpotter92 everywhere and can easily be seen around on several places like IRC, phpBB community, GitHub etc. I can be contacted at hjpotter92@iitkgp.ac.in

This will be my first project and I'm really excited towards it.

Excerpts from linked RFC
Here are some points/quotes from the previously linked RFC thread.
  • From imkingdavid
    I think converting to PDO would be a great idea. It would be ton of work, but I think it would be a lot more efficient and cleaner.
  • From naderman
    I would very much like to see these as an alternative to the existing drivers. They could especially be used as a basis for future drivers. If they work just as well they could theoretically replace the existing ones.
  • From igorw
    If other things come up it could always be pushed back to 3.2. I'd personally like to use this chance and improve the code base.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [GSoC-2013] Introduce PDO for MySQL

Post by Oleg » Fri Apr 26, 2013 11:21 pm

The way this should be done is as follows:

1. Separate database connectivity from SQL generation (what I called "dialects"). Then the same SQL dialect can be used with multiple database libraries (e.g. mysql/mysqli/mysqlnd/pdo_mysql).

2 .Create a driver which uses pdo and the mysql SQL dialect.

3. Create a pdo postgresql driver. When this is done, a pdo base class should be created for common pdo code.

4. Create a pdo sqlite3 driver.

If done correctly (and pdo api is not a disaster), there should be very little code in database-specific pdo drivers with most of the code residing in the base pdo driver.

For dialects, see https://github.com/phpbb/phpbb3/pull/605.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [GSoC-2013] Introduce PDO for MySQL

Post by Oleg » Fri Apr 26, 2013 11:31 pm

And the unavailable repository is here: https://github.com/igorw/phpbb3/compare ... e/dbal-pdo

hjpotter92
Registered User
Posts: 6
Joined: Mon Apr 08, 2013 10:15 pm

Re: [GSoC-2013] Introduce PDO for MySQL

Post by hjpotter92 » Sat Apr 27, 2013 6:55 pm

Oleg wrote:And the unavailable repository is here: https://github.com/igorw/phpbb3/compare ... e/dbal-pdo
Hi, thanks for providing this repository. Will read them and respond soon.
Oleg wrote:The way this should be done is as follows:
1. Separate database connectivity from SQL generation (what I called "dialects"). Then the same SQL dialect can be used with multiple database libraries (e.g. mysql/mysqli/mysqlnd/pdo_mysql).
2. Create a driver which uses pdo and the MySQL SQL dialect.
This is exactly what I plan to work on. I'm thinking that a separate pdo_query_build class can also be created.

Thank you for the very helpful tips.

hjpotter92
Registered User
Posts: 6
Joined: Mon Apr 08, 2013 10:15 pm

Re: [GSoC-2013] Introduce PDO for MySQL

Post by hjpotter92 » Sun Apr 28, 2013 8:14 pm

Hi

After going through the repository I think it is similar to what I am planning to do. But the user has inherited dbal and phpbb_db_query_driver. I don't know whether this is a good approach as I was planning more towards inheriting the PDO class itself.

Post Reply