<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Working Beta &#187; PHP</title>
	<atom:link href="http://seeds.workingbeta.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://seeds.workingbeta.com</link>
	<description>a bounch of nearly working code</description>
	<lastBuildDate>Wed, 10 Feb 2010 21:25:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ready&#8230; set&#8230; go!</title>
		<link>http://seeds.workingbeta.com/2009/05/14/ready-set-go/</link>
		<comments>http://seeds.workingbeta.com/2009/05/14/ready-set-go/#comments</comments>
		<pubDate>Thu, 14 May 2009 18:44:22 +0000</pubDate>
		<dc:creator>gc</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[RAD]]></category>
		<category><![CDATA[VISUAL PHP]]></category>

		<guid isPermaLink="false">http://seeds.workingbeta.com/?p=49</guid>
		<description><![CDATA[Hi all,
so much time since my last post! I&#8217;ve been involved into so many interesting projects that I could&#8217;t even login.
In the meantime a brand new side project idea is born.. All stats looking at the bleeding edge of the CMS/CMR/Framework panorama that I&#8217;ve encountered in the last month. None of them is really well [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,<br />
so much time since my last post! I&#8217;ve been involved into so many interesting projects that I could&#8217;t even login.</p>
<p>In the meantime a brand new side project idea is born.. All stats looking at the bleeding edge of the CMS/CMR/Framework panorama that I&#8217;ve encountered in the last month. None of them is really well suite for rapid application developement in  L(W)AMP environments. What is missing actually is a real visual IDE that fits into your browsers, and helps you deploy a consisten, secure, fast paced application starting from a simple set of tables/relations.</p>
<p>Something like the old visual basic stuff, but integrated with all the latest AJAX widgets and user experience. why should people still develop every single template/form/interface instead of simply concentrate in business logic?</p>
<p>so stay tuned, first lines of code are ready, as usual with prototype &amp; usual suspects in the frontline.<br />
I will publish one module/element/schema/idea per week, any help is greatly appreciated!!</p>
]]></content:encoded>
			<wfw:commentRss>http://seeds.workingbeta.com/2009/05/14/ready-set-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>managing [many] uploaded files</title>
		<link>http://seeds.workingbeta.com/2008/12/11/managing-many-uploaded-files/</link>
		<comments>http://seeds.workingbeta.com/2008/12/11/managing-many-uploaded-files/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 22:44:10 +0000</pubDate>
		<dc:creator>gc</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[multimedia]]></category>
		<category><![CDATA[thumbnail generation]]></category>

		<guid isPermaLink="false">http://seeds.workingbeta.com/?p=43</guid>
		<description><![CDATA[most  web applications have to deal with user provided files. Being them photos, word files, compressed archives, the big problem is what can happen when they become to be so many that become to reach the system limits of your filesystem.
Just think about sites like myspace, hacebook, flikr: they must provide upload features for [...]]]></description>
			<content:encoded><![CDATA[<p>most  web applications have to deal with user provided files. Being them photos, word files, compressed archives, the big problem is what can happen when they become to be so many that become to reach the system limits of your filesystem.<br />
Just think about sites like myspace, hacebook, flikr: they must provide upload features for millions of files/day and every each node of their webfarm cluser should be able to get it in milliseconds.<br />
The solution I usually provide in such case, creates a n-levels of directoryes  generating a unique 32-chars wide filename foreach file uploaded and then storing it. this method can fulfill the usual requirements for a medium sized high traffic application, and can store millions of files with no fear for performances.<br />
Each file can be retrieved with a simple numeric ID or a supersecret 32bit key adding security or applications requiring privacy protection.<br />
Also ther&#8217;s thumbnail generating method with caching mechanism if eeded.</p>
<p><a href="http://www.workingbeta.com/seeds/class.multimedia.php.zip">here</a> you can find it: too much code to explain, but if you don&#8217;t understand something, let me know</p>
]]></content:encoded>
			<wfw:commentRss>http://seeds.workingbeta.com/2008/12/11/managing-many-uploaded-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>class.tree.php</title>
		<link>http://seeds.workingbeta.com/2008/11/24/classtreephp/</link>
		<comments>http://seeds.workingbeta.com/2008/11/24/classtreephp/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 12:07:41 +0000</pubDate>
		<dc:creator>gc</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Seeds]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://seeds.workingbeta.com/?p=33</guid>
		<description><![CDATA[Trees are all around us&#8230; inside and outside our computers. As you may have already seen on your daily basis work, when you deal with tree-like structures binded to tables into your DB, you set something like

id  &#124;  id_father  &#124;      name     &#124; other [...]]]></description>
			<content:encoded><![CDATA[<p>Trees are all around us&#8230; inside and outside our computers. As you may have already seen on your daily basis work, when you deal with tree-like structures binded to tables into your DB, you set something like</p>
<blockquote><p><code><br />
id  |  id_father  |      name     | other datas<br />
01  |                00  |      root           | ...<br />
02  |                01  |  sub node | ...<br />
</code></p></blockquote>
<p>this kind of data structure is usually managed via recursion, and in web applications is useful to store site menu, product categories,  file-system alike apps and so on.<br />
The class i&#8217;m seeding here does all the dirty job giving you the possibility to</p>
<ul>
<li>use custom callback to modify the default behaviour [&lt;ul&gt;&lt;li&gt; sequence]</li>
<li>minimize/maximize function [for folder-like interfaces]</li>
<li>navigation path serialization</li>
</ul>
<p>those are the methods usually needed for day-to-day work with trees.<br />
<a href="http://workingbeta.com/seeds/class.tree.zip">here</a> you find all the code, but I&#8217;d like to poin out two things that [IMHO] really teach something to the average PHP programmer</p>
<ul>
<li>in the <strong>constructor</strong> 3 arrays are build as properties starting from the original array: arrayById, arrayByFather, arrayHasChild. I don&#8217;t know if it would be faster using array_find.. but once we&#8217;ve made the proper index association, ther&#8217;s no need for the original array to be parsed again.</li>
<li>use of $$ for the callback function: not so many people knows this sintax, but it&#8217;s worth a try</li>
</ul>
<p>the rest is really simple, and it&#8217;s well commented as well.</p>
<p>of course it fits perfectly with the standard output from dbmanager class presented <a href="http://seeds.workingbeta.com/2008/11/18/classdbmanagerphp/">here</a>. Set up your table in an appropriate way, make your assocQuery call and use your tree in no time.</p>
]]></content:encoded>
			<wfw:commentRss>http://seeds.workingbeta.com/2008/11/24/classtreephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>class.dbmanager.php</title>
		<link>http://seeds.workingbeta.com/2008/11/18/classdbmanagerphp/</link>
		<comments>http://seeds.workingbeta.com/2008/11/18/classdbmanagerphp/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 15:51:28 +0000</pubDate>
		<dc:creator>gc</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[dbmanagement]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://seeds.workingbeta.com/?p=19</guid>
		<description><![CDATA[here we go, a simple, very basic class to manage DB connections; I know there are so many around BUT

it&#8217;s very lightweight because it:
makes use of the &#8220;singleton&#8221; pattern, so you can start make a mess with patterns [if you've never do so]
ther&#8217;s soo much room for improvement
since I use it on an almost everyday [...]]]></description>
			<content:encoded><![CDATA[<p>here we go, a simple, very basic class to manage DB connections; I know there are so many around <strong>BUT</strong></p>
<ol>
<li>it&#8217;s very lightweight because it:</li>
<li>makes use of the &#8220;<a href="http://en.wikipedia.org/wiki/Singleton_pattern" target="_blank">singleton</a>&#8221; pattern, so you can start make a mess with <a href="http://en.wikipedia.org/wiki/Design_pattern" target="_blank">patterns</a> [if you've never do so]</li>
<li>ther&#8217;s soo much room for improvement</li>
<li>since I use it on an almost everyday basis anyother of my seeds will use it, so get used to it!</li>
</ol>
<p>When you deal with mysql connections you should keep in mind that every single connection takes its load or system resources, and if you don&#8217;t pay attentio you could easily end up into a &#8216;<em>too many connections</em>&#8216; error and a faulty applications.<br />
The very first solutions would be trying to use persistent connections, and this works very well on the mysql side: every page builds just one connection. The singleton pattern is chosen here because off it has a very low footprint into system resources: this means that you free more resources for the rest of your <span style="text-decoration: line-through;">crappy</span> code.</p>
<p>After creating your <strong>dbmanager</strong> Object, you have to <strong>dbmanager::connect </strong>giving host, user, pwd, db as always. from now on, you will have basically two methods:</p>
<p style="text-align: center;"><strong>dbmanager::assocQuery($sql)</strong> and <strong>dbmanager::sqlQuery($sql)</strong></p>
<p>those two methods just query the database with the given query [there are also some nice counters if you wanna know how many querys ar made for every page you build].<br />
The nice thing about dbmanager::assocQuery($sql) is how the result is returned: an associative array with fieldnames as keys: that&#8217;s really useful when you then have to cycle through your recordset and build tables, analyze data and so on.</p>
<blockquote><p><code><br />
$db=new dbconnection("mysql");<br />
$db-&gt;connect($host,$login,$password,$database);<br />
$recordset=$db-&gt;assocQuery("SELECT * FROM TABLENAME WHERE CONDITIONS...");<br />
foreach($recordset as $record){<br />
&nbsp;&nbsp;&nbsp;&nbsp;// here goes your code<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</code>
</p></blockquote>
<p>very straightforward, isn&#8217;t it???</p>
<p>uh.. the code is <a href="http://www.workingbeta.com/seeds/dbmanager.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://seeds.workingbeta.com/2008/11/18/classdbmanagerphp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>__autoload</title>
		<link>http://seeds.workingbeta.com/2008/11/13/__autoload/</link>
		<comments>http://seeds.workingbeta.com/2008/11/13/__autoload/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 12:19:28 +0000</pubDate>
		<dc:creator>gc</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[__autoload]]></category>

		<guid isPermaLink="false">http://seeds.workingbeta.com/?p=10</guid>
		<description><![CDATA[don&#8217;t know if you already use this
function __autoload($class){
&#160;&#160;&#160;&#160;# autoloading of a class #
&#160;&#160;&#160;&#160;if (file_exists("classes/class.".$class.".php"))
&#160;&#160;&#160;&#160;include_once("classes/class.".$class.".php");
&#160;&#160;&#160;&#160;else print "Failed to auto-load classes/class.{$class}.php";
&#160;&#160;&#160;&#160;}

it&#8217;s a little snippet of PHP code who take care of autoloading a class when you try to use it and the relevant definition file hasn&#8217;t still been loaded.
As you can see, if you use a bit [...]]]></description>
			<content:encoded><![CDATA[<p>don&#8217;t know if you already use this</p>
<blockquote><p><code><br />function __autoload($class){<br />
&nbsp;&nbsp;&nbsp;&nbsp;# autoloading of a class #<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (file_exists("classes/class.".$class.".php"))<br />
&nbsp;&nbsp;&nbsp;&nbsp;include_once("classes/class.".$class.".php");<br />
&nbsp;&nbsp;&nbsp;&nbsp;else print "Failed to auto-load classes/class.{$class}.php";<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</code></p></blockquote>
<p>it&#8217;s a little snippet of PHP code who take care of autoloading a class when you try to use it and the relevant definition file hasn&#8217;t still been loaded.<br />
As you can see, if you use a bit of naming convention and a solid file structure it could resolve many problems, expecially the neverending list of file inclusions at the beginning of your scripts.</p>
<p>Maybe some tweaks should be necessary to solve securiti issues, if you have any&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://seeds.workingbeta.com/2008/11/13/__autoload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
