PHP 5.3 full-blown ActiveRecord |
[eluser]jpfuentes[/eluser]
A quick search to find an implementation of active record for php on google is discouraging when one considers the state of ActiveRecord for Ruby on Rails. The reader will notice that the top results are from very old posts and the rest of the results preview minimial implementations. Of course, eventually, PHP will see a robust active record similar to RoR. Fortunately, that time is now, thanks to PHP 5.3 and the beneficial new features: closures, late static binding, and namespaces. Please take a look here: PHP 5.3 ActiveRecord
[eluser]Dam1an[/eluser]
Hi, welcome to the forums Have you tried using this with CI yet? does it work well? I'bve not looked into it yet, but have bookmarked it for when I have some time to look into it
[eluser]jpfuentes[/eluser]
No, I have not tried this with CI yet. I have used the earlier version with a custom framework. It can be used stand-alone or very easily added as a component to a framework. Basically there are only two configuration pieces you need: 1) declare the directory of the models 2) declare dsn strings like so -> array('development' => 'mysql://test:[email protected]/test');. As you can see, it wouldn't take much to use it for any framework, because it also makes use of spl_autoload which means you can invoke any class and it will try to find/load/require that class based on your model directory. It definitely works well and we have written a lot of tests with phpunit.
[eluser]xwero[/eluser]
Please add a download link. It's easy to create code snippets that show how something works without providing that code that powers it.
[eluser]Dam1an[/eluser]
Quote:We are hoping to have the code hosted on launchpad or the like within a week or two and a website with documentation. Be sure to check back here shortly for updates It would appear its a work in progress (I only just found that out now that you pointed out the lack of download link, so I actually tried reading the intro ![]()
[eluser]jpfuentes[/eluser]
We are going to try to fix any remaining issues, improve documentation, and then host it on launchpad this weekend. Hopefully, then you can have something to look at.
[eluser]jpfuentes[/eluser]
After a quick look at their implementation I see that it is missing many of the features we have included such as: validations, callbacks, complex relationships, dynamic finders (e.g.: Author::find_by_first_name('John');, finders with options like: group,order,select,joins, serialization with options.
[eluser]jpfuentes[/eluser]
I've got an update for anyone that is interested! Catch the latest post here: http://www.derivante.com/2009/05/19/php-...a-testing/. We've put up a number of examples to show you just how easy it is to use. We've also got the code hosted on launchpad now: http://launchpad.net/php-activerecord Enjoy.
[eluser]oddman[/eluser]
I'm going to have to have a play with this, as I too believe that this is a massively missing component in PHP (though you wouldn't need 5.3 to do it, it just makes it easier). That said, Doctrine is a fantastic ORM that has been around for some time. |
Welcome Guest, Not a member yet? Register Sign In |