Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
Creating Magic Methods in PHP
prostoalex
follow
0
8-14-2007 12:43 AM
266 views
tags:
php
,
programming
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Related Clips
Make a Gratitude Adjustment
11 Most Mysterious People
Most Incredible Storms of All Times : 5 Un...
Obamania
How are creative personalities different
top ten obscure google search tricks
antivirus 2009
More clips from
prostoalex
The Complete Guide for You to Become an Al...
Git Magic
The Art of Engineering
Today's Top Clips
Joint Chiefs Planned Terror Attacks in U.S A...!
19 Ways to Enhance Your Sense of Humor
Denmark's Kinder, Gentler System of Eugenics
To see our behavior from different perspective
Christmas Colors for the White House: Red, White and Impeach
Mothers 'Killed Sons to End War'
Where are all the Acorns?
A New Picture
Antarctic peninsula marine life
He's Not Black
visit the
Top Clips page
View the Top Clips from
August 14, 2007
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://www.clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/04740407-845d-4cc7-9bc4-f4c6b375c39f/384747FA-D6B3-4AC7-8329-371DE99CE918/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://www.chriscassell.net/log/2007/08/09/creating_magic_.html" href="http://www.chriscassell.net/log/2007/08/09/creating_magic_.html" style="font-size: 11px;">www.chriscassell.net</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.chriscassell.net/log/2007/08/09/creating_magic_.html"><P>I’ve learned a lot of things from various open source frameworks, especially <A href="http://cakephp.org/">CakePHP</A>. One of the most impressive things about Cake, and Ruby on Rails for that matter, is its magic methods in its data model class, <CODE>findBy</CODE> and <CODE>findAllBy</CODE> which allow you to query the database by calling a non-existent method like <CODE>findAllByColor ('blue')</CODE>. I’ve implemented similar methods in the home-grown framework that I use at work. Here’s how to do it.</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.chriscassell.net/log/2007/08/09/creating_magic_.html"><P>Through its <A href="http://en.wikipedia.org/wiki/Method_overloading">overloading</A> mechanism, PHP allows you to catch calls to methods that don’t exist. You do need to be using classes and generally good object-oriented techniques in order to do this, but you know that, right?</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.chriscassell.net/log/2007/08/09/creating_magic_.html"><P>Here’s the catch: overloading is native to PHP5, but needs some coersion in PHP4.</P></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/384747FA-D6B3-4AC7-8329-371DE99CE918/blog/" title="blog or email this clip"><img src="http://content9.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK