<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Using PHP Generic Objects To Organize Your&#160;Code</title> <atom:link href="http://davidwalsh.name/php-generic-objects-organize-code-class/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/php-generic-objects-organize-code-class</link> <description>PHP, CSS, MooTools, jQuery, and Everything Else</description> <lastBuildDate>Mon, 22 Mar 2010 03:26:22 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Tim</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-16260</link> <dc:creator>Tim</dc:creator> <pubDate>Thu, 25 Feb 2010 22:51:54 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-16260</guid> <description>Simplify by usingmysql_fetch_object($row, &#039;generic&#039;)This will populate all the fields of the given object using returned rows. It returns the new object.</description> <content:encoded><![CDATA[<p>Simplify by using</p><p>mysql_fetch_object($row, &#8216;generic&#8217;)</p><p>This will populate all the fields of the given object using returned rows. It returns the new object.</p> ]]></content:encoded> </item> <item><title>By: 網站製作學習誌 &#187; [Web] 連結分享</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-13934</link> <dc:creator>網站製作學習誌 &#187; [Web] 連結分享</dc:creator> <pubDate>Wed, 25 Nov 2009 02:44:35 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-13934</guid> <description>[...] Using PHP Generic Objects To Organize Your Code [...]</description> <content:encoded><![CDATA[<p>[...] Using PHP Generic Objects To Organize Your Code [...]</p> ]]></content:encoded> </item> <item><title>By: Quick Tip: PHP &#38; Possessive Punctuation - News from Tech</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-11860</link> <dc:creator>Quick Tip: PHP &#38; Possessive Punctuation - News from Tech</dc:creator> <pubDate>Sat, 12 Sep 2009 20:37:01 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-11860</guid> <description>[...] Using PHP Generic Objects To Organize Your Code [...]</description> <content:encoded><![CDATA[<p>[...] Using PHP Generic Objects To Organize Your Code [...]</p> ]]></content:encoded> </item> <item><title>By: Thomas Eng</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-10204</link> <dc:creator>Thomas Eng</dc:creator> <pubDate>Tue, 07 Jul 2009 11:07:25 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-10204</guid> <description>You could alse do:function puts($s) {
print $s . &quot;\n&quot;;
}class Object {
function _&#95;construct() {
$a = array&#95;shift( func&#95;get&#95;args() );
foreach($a as $key =&gt; $value) {
$this-&gt;{$key} = $value;
}
}
}
$o = new Object(array( &quot;name&quot; =&gt; &quot;John Doe&quot;, &quot;age&quot; =&gt; 31) );
puts($o-&gt;name);
puts($o-&gt;age); </description> <content:encoded><![CDATA[<p>You could alse do:</p><p>function puts($s) {<br
/> print $s . &#8220;\n&#8221;;<br
/> }</p><p>class Object {<br
/> function _&#95;construct() {<br
/> $a = array&#95;shift( func&#95;get&#95;args() );<br
/> foreach($a as $key =&gt; $value) {<br
/> $this-&gt;{$key} = $value;<br
/> }<br
/> }<br
/> }<br
/> $o = new Object(array( &#8220;name&#8221; =&gt; &#8220;John Doe&#8221;, &#8220;age&#8221; =&gt; 31) );<br
/> puts($o-&gt;name);<br
/> puts($o-&gt;age);</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-9964</link> <dc:creator>David Walsh</dc:creator> <pubDate>Mon, 22 Jun 2009 12:31:54 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-9964</guid> <description>&lt;p&gt;@azwan:  I don&#039;t do anything too terrible advanced with this class, although you could.  That&#039;s the beauty in its simplicity!&lt;/p&gt;</description> <content:encoded><![CDATA[<p>@azwan:  I don&#8217;t do anything too terrible advanced with this class, although you could.  That&#8217;s the beauty in its simplicity!</p> ]]></content:encoded> </item> <item><title>By: azwan</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-9959</link> <dc:creator>azwan</dc:creator> <pubDate>Mon, 22 Jun 2009 09:34:47 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-9959</guid> <description>David, thanks for sharing this. I just started learning about OOP and this class really helps. Simple and seems practical.Anyway, some questions to ask (maybe other ppl can also help)Will you use this generic class as a class for other classes to inherit/extend?
What about retrieving mulitple records (will it be array in array) in vars?I&#039;m thinking of using the class for mainly data retrieving/manipulation from database.Thanks in advance.</description> <content:encoded><![CDATA[<p>David, thanks for sharing this. I just started learning about OOP and this class really helps. Simple and seems practical.</p><p>Anyway, some questions to ask (maybe other ppl can also help)</p><p>Will you use this generic class as a class for other classes to inherit/extend?<br
/> What about retrieving mulitple records (will it be array in array) in vars?</p><p>I&#8217;m thinking of using the class for mainly data retrieving/manipulation from database.</p><p>Thanks in advance.</p> ]]></content:encoded> </item> <item><title>By: david</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-2661</link> <dc:creator>david</dc:creator> <pubDate>Fri, 08 Aug 2008 17:16:03 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-2661</guid> <description>&lt;p&gt;@Sat:  I&#039;ll fix this.  Stupid WordPress...&lt;/p&gt;</description> <content:encoded><![CDATA[<p>@Sat:  I&#8217;ll fix this.  Stupid WordPress&#8230;</p> ]]></content:encoded> </item> <item><title>By: Sat Pirott</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-2660</link> <dc:creator>Sat Pirott</dc:creator> <pubDate>Fri, 08 Aug 2008 17:01:57 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-2660</guid> <description>Hey Dave! Nice class you have there! Did not think about this option before. But anyways, there is a big &#039;error&#039; (if I can call it like that) which I like to point to. It&#039;s not in the code, rather &#039;visual&#039;. After the heading &quot;Database Usage&quot; the whole content get&#039;s bold, up to here! Dunno why, but it looks REALLY ugly! Hope you&#039;ll fix that for others :-).</description> <content:encoded><![CDATA[<p>Hey Dave! Nice class you have there! Did not think about this option before. But anyways, there is a big &#8216;error&#8217; (if I can call it like that) which I like to point to. It&#8217;s not in the code, rather &#8216;visual&#8217;. After the heading &#8220;Database Usage&#8221; the whole content get&#8217;s bold, up to here! Dunno why, but it looks REALLY ugly! Hope you&#8217;ll fix that for others :-).</p> ]]></content:encoded> </item> <item><title>By: Marc A. Champlain</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-2496</link> <dc:creator>Marc A. Champlain</dc:creator> <pubDate>Wed, 30 Jul 2008 11:51:07 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-2496</guid> <description>I code only in PHP5 so I don&#039;t know for earlier version, but you could simply do:$person = (object) null;  // or   $person = new stdClass();
$person-&gt;name = &quot;Marc&quot;;
$person-&gt;age = &quot;28&quot;;
echo $person-&gt;age; </description> <content:encoded><![CDATA[<p>I code only in PHP5 so I don&#8217;t know for earlier version, but you could simply do:</p><p>$person = (object) null;  // or   $person = new stdClass();<br
/> $person-&gt;name = &#8220;Marc&#8221;;<br
/> $person-&gt;age = &#8220;28&#8243;;<br
/> echo $person-&gt;age;</p> ]]></content:encoded> </item> <item><title>By: Christian Roy</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class/comment-page-1#comment-238</link> <dc:creator>Christian Roy</dc:creator> <pubDate>Wed, 19 Dec 2007 16:01:17 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-238</guid> <description>IMHO, your class is too &quot;generic&quot; :)Seems to be an excuse to use OOP.I use Objects whenever I feel it is necessary, but I remind myself that every tool has its purpose.  I wouldn&#039;t use your class  everywhere like you seem to be doing.  I would use an ORM: something like Propel or Doctrine or even DB_DataObject (PEAR) or PDO for handling data from an SQL.  I would use a class like PEAR&#039;s Config for site-wide variables.  I try to avoid re-inventing the wheel and I use stuff that already exists as much as possible.Your code is very clean and almost perfectly consistent in its format.  I like that :)  Your braces in your ctor should follow the same format as your other methods.You should use an existing documentation format like phpDocumentor to automatically generate API docs.I agree with the others about using magic functions if you would be working in a PHP5 only environment.Thank you for sharing your thoughts with us. :)</description> <content:encoded><![CDATA[<p>IMHO, your class is too &#8220;generic&#8221; :)</p><p>Seems to be an excuse to use OOP.</p><p>I use Objects whenever I feel it is necessary, but I remind myself that every tool has its purpose.  I wouldn&#8217;t use your class  everywhere like you seem to be doing.  I would use an ORM: something like Propel or Doctrine or even DB_DataObject (PEAR) or PDO for handling data from an SQL.  I would use a class like PEAR&#8217;s Config for site-wide variables.  I try to avoid re-inventing the wheel and I use stuff that already exists as much as possible.</p><p>Your code is very clean and almost perfectly consistent in its format.  I like that :)  Your braces in your ctor should follow the same format as your other methods.</p><p>You should use an existing documentation format like phpDocumentor to automatically generate API docs.</p><p>I agree with the others about using magic functions if you would be working in a PHP5 only environment.</p><p>Thank you for sharing your thoughts with us. :)</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 7/19 queries in 0.019 seconds using disk

Served from: davidwalsh.name @ 2010-03-22 04:26:31 -->