 | News Feed |
Sections
|
| feed this: |  |
ProDevTips.com: Extending PHP Doctrine Record - Check Box Groups
by Chris Cornutt August 12, 2008 @ 13:26:36
In the third part of the series dealing with using Doctrine in your PHP applications, ProDevTips has this third part looking at a method for extending the tool's current functionality.
I simply knew we would need the extension capability that the Mdl class allows for sooner or later, I didnâ'™t expect it to be this soon though. The main problem here is saving a many to many relationship straight to the database from the $_POST array, to do that we can extend Doctrine Record with a new function I have named fromArrayExt which adds something extra to the normal fromArray method.
He shows how to extend the classes to create custom handlers for a grouping of checkboxes. The new code automatically handles their submitted values and pushes them directly into the database (with a simple save() call).
voice your opinion now!
doctrine record tutorial checkbox extend group
Arnold Daniels' Blog: A dark corner of PHP class casting
by Chris Cornutt February 20, 2008 @ 12:08:00
In this blog entry Arnold Daniels talks about an issue he had in the past (needing a bit more functionality than the PEAR DB library could offer) and how he ended up solving it with what he calls a "dark corner" of PHP - class casting.
PHP has a function serialize, which can create a hash from any type of variable, scalars, array, but objects as well. Using the unserialize function, PHP can recreate the variable from the serialized hashed. If we look at how an object is serialized, we see only the properties and the class name are stored.
His method allows for class manipulation via changes to the serialized class information (like changing the value of the name parameter). His "casttoclass()" function makes changing this value simple.
voice your opinion now!
class casting serialize extend parent child
|
Community Events
Don't see your event here? Let us know!
|