<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>Orchid</title>
	<link>http://orchid.phpxperts.net</link>
	<description>PHP framework for the rest of us</description>
	<pubDate>Thu, 10 Apr 2008 16:19:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>part 2: working with models</title>
		<link>http://orchid.phpxperts.net/2008/04/10/part-2-working-with-models/</link>
		<comments>http://orchid.phpxperts.net/2008/04/10/part-2-working-with-models/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 16:11:44 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2008/04/10/part-2-working-with-models/</guid>
		<description><![CDATA[as promised, orchid comes with real flexibility which lets you design your application in less time. in orchid, there is a nice active record object which helps you to interact with your database very easily. beside that, you can also write your own model class to facilitate comples business logics and operations. in this installment, [...]]]></description>
			<content:encoded><![CDATA[<p>as promised, <a href="http://orchidframework.net">orchid</a> comes with real flexibility which lets you design your application in less time. in orchid, there is a nice active record object which helps you to interact with your database very easily. beside that, you can also write your own model class to facilitate comples business logics and operations. in this installment, we will learn how to achieve maximum speed and benefit by using the builtin model library of orchid with a toppings of the active record library. </p>
<p>2.1 <b>connecting to a database</b></p>
<p>the built in data access libraries in orchid will help you to connect to mysql, postgresql, mssqlserver and sqlite in a minute. beside that you can also connect to other database engines by using native wrapper of pdo. all you have to do is to add a few lines in the configuration file and whoa, you are connected. don&#8217;t you believe me? lets see</p>
<p>create a file named <i>configs.php</i> in <b>app/config/configs.php</b> with the following contents<br />
<code><br />
$configs['db']['production']['dbname']="";<br />
$configs['db']['production']['dbhost']="";<br />
$configs['db']['production']['dbuser']="";<br />
$configs['db']['production']['dbpwd']="";<br />
$configs['db']['production']['persistent']="";<br />
$configs['db']['production']['dbtype']="";<br />
</code></p>
<p>in orchid you can have as many database state (such as production, development or whatever) as you want. in the example above, we named our db state as &#8220;production&#8221;. rest of the code is self explanatory, right? the only confusion you might have is about &#8220;persistent&#8221;. well, if you set it to true, the connection to your database stay alive as long as you are using the same connection strings, which will save some microseconds from connecting every time your script executes. </p>
<p>you are <b>not</b> done yet. there are some more configuration directives we have to add. we haven&#8217;t yet specified the type of our database and which db state orchid will use, lets do that. add the following two lines in your <b>configs.php</b></p>
<p><code><br />
$configs['db']['usedb']=""; //true or false<br />
$configs['db']['state']="development";<br />
</code></p>
<p>the value of &#8220;usedb&#8221; could be either one of &#8220;mysql&#8221;,&#8221;mysqli&#8221;,&#8221;pgsql&#8221;,&#8221;mssql&#8221;,&#8221;pdo&#8221; or &#8220;sqlite&#8221;. and using usedb you can tell orchid to use database engines or not. so you can save the connection parameters for use later by specifying the &#8220;usedb&#8221; parameter to &#8220;false&#8221;.</p>
<p>ding dong! you are connected to your favorite db engine in a minute, as said.</p>
<p>2.2 <b>good coding and bad coding while working with database</b></p>
<p>in orchid (and in most other framework possibly) you can directly use the internal dbmanager to execute sql, fetch the result and manipulate that through out your application. i have seen developers manipulating records in controllers, in views and skipped the most appropriate part where these manipulation should take part in fact, models. many of you dont make use of the models in your application and write the business logic entirely in your controller, feeding the inner monster of your application to be the most vigorous unmanageable giant. dont blame php as a tool to write unmanageable code because this unmanageable code solely depends on you - you. always try to use models to encapsulate the business logic and separate it from your controller. lets model do it&#8217;s job.</p>
<p>2.3 <b>working with models</b></p>
<p>in this section we will write a simple model and insert some data inside a table. here comes the schema of the table.</p>
<pre>
<code>
CREATE TABLE `comics` (
  `id` int(11) NOT NULL auto_increment,
  `comicname` varchar(255) default NULL,
  `comicurl` varchar(255) default NULL,
  PRIMARY KEY  (`id`)
)
</code>
</pre>
<p>in orchid, you can instantly create a reference to any table in your database by auto model feature of orchid, which looks like the code below, which will reside in a controller. </p>
<p><code><br />
$comicsmocdel = $this-&gt;model-&gt;comics;<br />
</code></p>
<p>orchid will dynmically create a reference of the &#8220;comics&#8221; table instantly, no more hassle for you. but there are significant causes why we will write models by coding it. the auto models support only the very basic data manipulation. if you want to encapsulate business logic inside, we definitely need to write the code inside. lets learn first how to work with a auto model like this one. </p>
<p>a model in orchid supports the following methods</p>
<ul>
<li>selecting data</li>
<li>basic joining</li>
<li>insert</li>
<li>delete</li>
<li>update</li>
<li>finding based on criteria</li>
</ul>
<p>as we have already created a model, lets make use of it. the following piece of code will insert a record in the <b>comics</b> table using the model. </p>
<p><code><br />
$comicsmodel = $this-&gt;model-&gt;comics;<br />
$comicsmodel-&gt;comicname = "Nancy and Sluggo";<br />
$comicsmodel-&gt;comicurl = "http://comics.com/comics/nancy/index.html";<br />
$comicsmodel-&gt;insert();<br />
</code></p>
<p>this is really simple to work with models in orchid, like as i said, the above example will insert a data in your data table named &#8220;comics&#8221;. now lets see how we can modify the existing data. in the following example we will change the name of the comic to the data which we&#8217;d just inserted. </p>
<p><code><br />
//inside the controller action<br />
$comicsmodel = $this-&gt;model-&gt;comics;<br />
$data = $comicsmodel-&gt;find("comicname = 'Nancy and Sluggo'");<br />
print_r($data);<br />
if(!empty($data))<br />
{<br />
	$comicsmodel-&gt;comicname="Nancy &amp; Sluggo";<br />
	$comicsmodel-&gt;update();<br />
}<br />
</code></p>
<p>the find method can take any clause and find records according to that. similarly as update and insert, you can delete records using models in orchid.</p>
<p>in upcoming tutorials we will learn more on models and encapsulating business logic by writing in by our own <img src='http://orchid.phpxperts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2008/04/10/part-2-working-with-models/feed/</wfw:commentRss>
		</item>
		<item>
		<title>part 1: getting started with orchid</title>
		<link>http://orchid.phpxperts.net/2008/04/06/part-1-getting-started-with-orchid/</link>
		<comments>http://orchid.phpxperts.net/2008/04/06/part-1-getting-started-with-orchid/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 18:29:32 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2008/04/06/part-1-getting-started-with-orchid/</guid>
		<description><![CDATA[today i was planning to start the documentation of orchid framework for the rest of us(?). so this one is the first installment of this series. you will find small tutorials everyday. just stick with the series and you will see how far we can fly you. time to get high  [please note that [...]]]></description>
			<content:encoded><![CDATA[<p>today i was planning to start the documentation of orchid framework for the rest of us(?). so this one is the first installment of this series. you will find small tutorials everyday. just stick with the series and you will see how far we can fly you. time to get high <img src='http://orchid.phpxperts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> [please note that the text in this series will be all-small cap]</p>
<p><strong><u>getting started with orchid</u></strong></p>
<p>orchid is a small framework with bare necessities to kick start developing killer php web applications. this framework is not flooded with unnecessary features and libraries. it only contains the essential helpers and libraries to boost up your development, not slowing it down. orchid features a very short learning curve, which will keep you trouble free. small footprint and excellent profile will be your first choice, which you will definitely realize once you start realizing the power that orchid brings in your hand. long story short, orchid is the next framework going to rock.</p>
<p>you can checkout orchid from it&#8217;s subversion repository<br />
<code>svn checkout http://orchidframework.googlecode.com/svn/trunk/ orchidframework</code></p>
<p>orchid comes pre equipped with excellent configuration directives in a config file, which we will focus in details in the upcoming tutorials. for now lets just start as is.</p>
<p>to create your first application, we need to create a folder named &#8220;app&#8221; inside the <strong>orchidframework</strong> directory. after you create that, there will be three directories named app, core and tests.</p>
<p>in orchid, controllers reside in <strong>app/controllers</strong> directory. views (templates) reside in <strong>app/views/<em>controller_name</em>/</strong> directory, which means if the name of your controller is &#8220;blog&#8221;, all your views remains in <strong>app/views/blog/</strong> directory. lets create our first controller named &#8220;talk&#8221;.  the controller file will be <strong>app/controllers/talk.php. </strong></p>
<p>a controller in orchid is a normal php class file which extends the base controller class. all the public methods in a controller class are considered as action. a method named &#8220;base&#8221; is the primary action for all the controller in orchid. and for now, this is all the information you need to create your first controller in orchid.</p>
<p>lets write a sample action in our controller, named &#8220;base&#8221;</p>
<pre>&lt;?php
/**
 * the source file is app/controllers/talk.php
 */
class talk extends controller
{
	public function base()
	{
		echo "hello";
	}
}
?&gt;</pre>
<p>now you can run this controller by pointing your browser to the following location. i considered that you have hosted orchid in your document root (i.e <strong>/var/www/orchid</strong>)</p>
<p><code>http://localhost/orchid/talk</code></p>
<p>whoops, what have we done wrong? why do we get an error?</p>
<p>we are seeing this error because we didnt write our view (or template, whatever you call it) yet. and this is not a good coding practice to  output anthing directly from your controller. whatever the size of the output, you should display it by passing the data to a view first. this will ensure the consistency of your project through out the application. orchid is flexible, but keeping the word &#8220;flexibility with responsibility&#8221;</p>
<p>lets write the view file, named &#8220;&lt;i&gt;<em>base.php</em>&lt;/i&gt;&#8221; which will reside in<strong> app/views/talk/</strong> directory.</p>
<pre>&lt;?//the source file is app/views/talk/base.php?&gt;
&lt;?=$talkings;?&gt;</pre>
<p>so where from do we get the variable named $talkings? dont worry, you will have to pass it to the view from your controller. in fact through out your application you have to pass all the data to a view from the controller in almost every mvc framework and orchid is not the exception in this case. lets re write the controller</p>
<pre>&lt;?php
/**
 * the source file is app/controllers/talk.php
 */
class talk extends controller
{
	public function base()
	{
		$this-&gt;setViewParam("talkings","hello world");
	}
}
?&gt;</pre>
<p>now you will see the output <strong>&#8220;hello world&#8221;</strong> as output when you point your browser to http://localhost/orchid/talk</p>
<p>orchid is very flexible and if you need to raw output (for example after a ajax request) some content from your controller, you can even do that. orchid wont restrict you from not doing so, but what we really said is that for good coding you should follow this guideline.</p>
<p>so that&#8217;s it. getting started in orchid wont take more than 5 minutes and that is where the blessings of using a framework is in. in next tutorial we will learn how to use a model in orchid.</p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2008/04/06/part-1-getting-started-with-orchid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating a basic App with Orchid</title>
		<link>http://orchid.phpxperts.net/2008/03/18/creating-a-basic-app-with-orchid/</link>
		<comments>http://orchid.phpxperts.net/2008/03/18/creating-a-basic-app-with-orchid/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 05:33:19 +0000</pubDate>
		<dc:creator>mailtoaman</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<category><![CDATA[basic example]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2008/03/18/creating-a-basic-app-with-orchid/</guid>
		<description><![CDATA[Ok, lets try to create baby out of orchid  
Take her at your place for date:
Copy the orchid folder to a location of choice where you like to host the app.
Make sure she is vergin
There should not be any app folder inside the orchid folder.  If any, remove it.
Get inside of her, make [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, lets try to create baby out of orchid <img src='http://orchid.phpxperts.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><em><strong>Take her at your place for date:</strong></em></p>
<p>Copy the orchid folder to a location of choice where you like to host the app.</p>
<p><em><strong>Make sure she is vergin</strong></em></p>
<p>There should not be any app folder inside the orchid folder.  If any, remove it.</p>
<p><em><strong>Get inside of her, make her move&#8230;</strong></em><br />
Open up a console, go to the orchid directory. run:</p>
<p>$php cli.php skeleton test</p>
<p>You will find a new folder named app is created in orchid directory.</p>
<p><em><strong>The last drop&#8230;.</strong></em></p>
<p>run the following command:</p>
<p>$php cli.php controller main</p>
<p>Bingo.. orchid is a very good mother and wont take 9 months to create a baby. You can see your baby at:<br />
<strong><em>http://localhost/learn/test/orchidframework/index.php?main</em></strong></p>
<p>Don&#8217;t forget to change the url as required for your setup.</p>
<p><em><strong>Examining the baby:</strong></em></p>
<p>in orchid/app/controllers folder a new file is created named main.php</p>
<p>and two more files in orchid/app/views/main/ folder naming base.php and hello.php.</p>
<p>What they do is really simple and easy to understand.</p>
<p>Here is the controller file content:</p>
<blockquote><p><strong>class main extends controller<br />
{<br />
function base()<br />
{<br />
$this-&gt;view-&gt;set(&#8221;name&#8221;,&#8217;main&#8217;);<br />
}</strong></p>
<p><strong>function hello()<br />
{<br />
$this-&gt;view-&gt;set(&#8221;param1&#8243;,&#8217;World&#8217;);<br />
}<br />
} </strong></p></blockquote>
<p>and hello.php and base.php are normal php files.</p>
<p><em><strong>http://localhost/learn/test/orchidframework/index.php?main</strong></em></p>
<p>This line executes the <em><strong>base</strong></em> method of the controller named <strong>main</strong>. &#8216;Base&#8217; method is called implicitly if no explicit method is asked for.</p>
<p>and  <em><strong>http://localhost/learn/test/orchidframework/index.php?main/hello</strong></em></p>
<p>calls the <strong>hello</strong> method of the controller <strong>main</strong>.</p>
<p>Simple, eh ?</p>
<p>Just one more thing, you can pass values to the view from controller. Look at the <strong>hello</strong> method once again.</p>
<blockquote><p><em>$this-&gt;view-&gt;set(&#8217;param1&#8242;,&#8217;world&#8217;); </em></p></blockquote>
<p>And here how the <strong>param1</strong> is used in hello.php</p>
<blockquote><p><em>Hello &lt;?=$param1;?&gt;</em></p></blockquote>
<p>Orchid&#8217;s baby is really smart, right ?!!</p>
<p>Cheers <img src='http://orchid.phpxperts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2008/03/18/creating-a-basic-app-with-orchid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Update</title>
		<link>http://orchid.phpxperts.net/2008/01/25/update/</link>
		<comments>http://orchid.phpxperts.net/2008/01/25/update/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 14:24:23 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2008/01/25/update/</guid>
		<description><![CDATA[Recently we have added http object, blueprint css framework and RSS reader and writer class in orchid. Due to having some complexity, we decided to add support of open id in next stable release.
The project is running under heavy documentation. You can expect a beta very soon  
If you are interested to take part [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we have added http object, blueprint css framework and RSS reader and writer class in orchid. Due to having some complexity, we decided to add support of open id in next stable release.</p>
<p>The project is running under heavy documentation. You can expect a beta very soon <img src='http://orchid.phpxperts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you are interested to take part in documentation team, please drop me a mail.</p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2008/01/25/update/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Addition - http object</title>
		<link>http://orchid.phpxperts.net/2008/01/25/new-addition-http-object/</link>
		<comments>http://orchid.phpxperts.net/2008/01/25/new-addition-http-object/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 11:06:11 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2008/01/25/new-addition-http-object/</guid>
		<description><![CDATA[We have added a new object in orchid framework. This is an object to help you manage all remote operations (over HTTP) extremely easier. This is a wrapper of HTTP class that uses either cURL or fsockopen to harvest resources from the web. It supports a handy subset of functionalists of HTTP that are mostly [...]]]></description>
			<content:encoded><![CDATA[<p>We have added a new object in orchid framework. This is an object to help you manage all remote operations (over HTTP) extremely easier. This is a wrapper of HTTP class that uses either <strong>cURL</strong> or <strong>fsockopen</strong> to harvest resources from the web. It supports a handy subset of functionalists of HTTP that are mostly needed in day to day coding. Scripts who need to communicate with other servers will find it useful. If you’re looking to invoke any <strong>RESTful </strong>API and don’t want to bother adding a bunch of libraries for that simple thing, just put this class and you’re set.</p>
<ul>
<li>Can use both cURL and fsockopen.</li>
<li>Degrades to fsockopen if cURL not enabled.</li>
<li>Supports HTTP Basic authentication.</li>
<li>Supports defining custom request headers.</li>
<li>Supports defining connection timeout values.</li>
<li>Supports defining user agent and referral values.</li>
<li>Supports both user-defined and persistent cookies.</li>
<li>Supports secure connections (HTTPS) with and without cURL.</li>
<li>Supports adding requests parameters for both GET and POST.</li>
<li>Supports automatic redirection (maximum redirect can be defined).</li>
<li>Returns HTTP response headers and response body data separately.</li>
</ul>
<p>Thanks goes to <a href="http://www.phpfour.com/blog/2008/01/20/php-http-class/">Emran</a> for contributing this one <img src='http://orchid.phpxperts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2008/01/25/new-addition-http-object/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Domains Taken</title>
		<link>http://orchid.phpxperts.net/2007/12/29/domains-taken/</link>
		<comments>http://orchid.phpxperts.net/2007/12/29/domains-taken/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 14:44:35 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2007/12/29/domains-taken/</guid>
		<description><![CDATA[Two domains for orchid is taken today. They are
1. www.orchidframework.net
2. www.orchidframework.com
]]></description>
			<content:encoded><![CDATA[<p>Two domains for orchid is taken today. They are</p>
<p>1. <a href="http://www.orchidframework.net">www.orchidframework.net</a><br />
2. <a href="http://www.orchidframework.com">www.orchidframework.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2007/12/29/domains-taken/feed/</wfw:commentRss>
		</item>
		<item>
		<title>We are planning to integrate OpenId and BP</title>
		<link>http://orchid.phpxperts.net/2007/12/25/we-are-planning-to-integrate-openid-and-bp/</link>
		<comments>http://orchid.phpxperts.net/2007/12/25/we-are-planning-to-integrate-openid-and-bp/#comments</comments>
		<pubDate>Tue, 25 Dec 2007 06:01:30 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2007/12/25/we-are-planning-to-integrate-openid-and-bp/</guid>
		<description><![CDATA[
Not both of them are in same group. OpenID is one of the most successful single sign on solution for open source developers and BP is Blueprint, a really nice CSS framework.
We are planning to bundle both of them in orchid in next release. Needless to say, BP will work as an optional choice for [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://files.bjorkoy.com/images/blueprint.png" alt="Blueprint CSS" align="top" border="0" height="83" hspace="5" width="339" /></p>
<p>Not both of them are in same group. OpenID is one of the most successful single sign on solution for open source developers and BP is Blueprint, a really nice CSS framework.</p>
<p><img src="http://www.stubbleblog.com/images/openid_logo.png" style="border: 0px none " alt="OpenID" align="left" border="0" height="120" hspace="5" width="320" />We are planning to bundle both of them in orchid in next release. Needless to say, BP will work as an optional choice for developers who will use Orchid.</p>
<p style="clear: both">Wait for the big time, we are sure that you will find it rock!</p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2007/12/25/we-are-planning-to-integrate-openid-and-bp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Models</title>
		<link>http://orchid.phpxperts.net/2007/12/24/using-models/</link>
		<comments>http://orchid.phpxperts.net/2007/12/24/using-models/#comments</comments>
		<pubDate>Mon, 24 Dec 2007 19:33:26 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2007/12/24/using-models/</guid>
		<description><![CDATA[Not a big deal in Orchid. If u have a table named &#8220;users&#8221; in your mysql database with the following structure, you can interact with it like this.

CREATE TABLE `users` &#40;
  `id` int&#40;11&#41; NOT NULL AUTO_INCREMENT,
  `username` varchar&#40;250&#41; DEFAULT NULL,
  `password` varchar&#40;32&#41; DEFAULT NULL,
  PRIMARY KEY  &#40;`id`&#41;
&#41; ENGINE=MyISAM

Here is how [...]]]></description>
			<content:encoded><![CDATA[<p>Not a big deal in Orchid. If u have a table named &#8220;users&#8221; in your mysql database with the following structure, you can interact with it like this.</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`users`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`id`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>,
  <span style="color: #ff0000;">`username`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
  <span style="color: #ff0000;">`password`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE=MyISAM</pre></div></div>

<p>Here is how to interact using a model</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #0000ff;">$usersmodel</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">model</span>-&gt;<span style="color: #006600;">users</span>;
<span style="color: #0000ff;">$usersmodel</span>-&gt;<span style="color: #006600;">username</span> = <span style="color: #ff0000;">&quot;test&quot;</span>;
<span style="color: #0000ff;">$usersmodel</span>-&gt;<span style="color: #006600;">password</span> = <span style="color: #ff0000;">&quot;testpass&quot;</span>;
<span style="color: #0000ff;">$usersmodel</span>-&gt;<span style="color: #006600;">insert</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$usersmodel</span>-&gt;<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;username = 'test'&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$usersmodel</span>-&gt;<span style="color: #006600;">username</span> = <span style="color: #ff0000;">&quot;tester&quot;</span>;
<span style="color: #0000ff;">$usersmodel</span>-&gt;<span style="color: #006600;">update</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>You dont need to write any code for this model &#8220;users&#8221;. It is auto generated using the active record library that comes with orchid. You can generate models by naming them same as table names in your database. Easy, huh?</p>
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2007/12/24/using-models/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Writing Inline Unit Tests in Orchid</title>
		<link>http://orchid.phpxperts.net/2007/12/24/writing-inline-unit-tests-in-orchid/</link>
		<comments>http://orchid.phpxperts.net/2007/12/24/writing-inline-unit-tests-in-orchid/#comments</comments>
		<pubDate>Mon, 24 Dec 2007 14:56:36 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2007/12/24/writing-inline-unit-tests-in-orchid/</guid>
		<description><![CDATA[Writing inline unit test makes it painless and hassle free. Orchid comes with a bundled unit test library which you can take full advantage of. Have a look at the following code to understand how to write your unit tests. No more &#8220;setup&#8221; and &#8220;teardown&#8221; for you  
Lets consider your controller is app/controllers/ut.php

&#60;?
class ut [...]]]></description>
			<content:encoded><![CDATA[<p>Writing inline unit test makes it painless and hassle free. Orchid comes with a bundled unit test library which you can take full advantage of. Have a look at the following code to understand how to write your unit tests. No more &#8220;setup&#8221; and &#8220;teardown&#8221; for you <img src='http://orchid.phpxperts.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Lets consider your controller is app/controllers/ut.php</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000000; font-weight: bold;">class</span> ut <span style="color: #000000; font-weight: bold;">extends</span> controller 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> base<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">use_view</span>=<span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #0000ff;">$name</span> = <span style="color: #ff0000;">&quot;Orchid&quot;</span>;
		unittest::<span style="color: #006600;">assertContains</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Orchid&quot;</span>,<span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0000ff;">$gmap</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">library</span>-&gt;<span style="color: #006600;">gmap</span>;
		<span style="color: #0000ff;">$location</span> = <span style="color: #0000ff;">$gmap</span>-&gt;<span style="color: #006600;">getGeoCode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;dhaka&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0000ff;">$longitude</span> = <span style="color: #0000ff;">$location</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'lon'</span><span style="color: #66cc66;">&#93;</span>;
		<span style="color: #0000ff;">$lattitude</span> = <span style="color: #0000ff;">$location</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'lat'</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
		unittest::<span style="color: #006600;">assertEqual</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$lattitude</span>,<span style="color: #ff0000;">&quot;23.709801&quot;</span><span style="color: #66cc66;">&#41;</span>;
		unittest::<span style="color: #006600;">assertEqual</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$longitude</span>,<span style="color: #ff0000;">&quot;23.709801&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now point your broswer to http://your_orchid_path/ut/base/unittest. You have to write &#8220;unittest&#8221; at the end to view the output of test cases from inline unit tests. Otherwise it will work as regular action and no unit test result will be displayed in output. Nice, huh?</p>
<p>Now see what it generates as a result of these assertions</p>
<p>Test <font color="green"><strong>passed</strong></font> in Method: <strong>base</strong>. Line: <strong>8</strong>. File: <strong>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\orchid\app\controllers\ut.php</strong>.<br />
Expected: <strong>Haystack has a needle named &#8216;Orchid&#8217;</strong>, Actual: <strong>Haystack has a needle named &#8216;Orchid&#8217;</strong>.</p>
<hr />Test <font color="green"><strong>passed</strong></font> in Method: <strong>base</strong>. Line: <strong>16</strong>. File: <strong>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\orchid\app\controllers\ut.php</strong>.<br />
Expected: <strong>23.709801</strong>, Actual: <strong>23.709801</strong>.</p>
<hr />Test <font color="red"><strong>failed</strong></font> in Method: <strong>base</strong>. Line: <strong>17</strong>. File: <strong>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\orchid\app\controllers\ut.php</strong>.<br />
Expected: <strong>23.709801</strong>, Actual: <strong>90.407112</strong>.</p>
<hr />
]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2007/12/24/writing-inline-unit-tests-in-orchid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Caching in Orchid is Easy</title>
		<link>http://orchid.phpxperts.net/2007/12/24/caching-in-orchid-is-easy/</link>
		<comments>http://orchid.phpxperts.net/2007/12/24/caching-in-orchid-is-easy/#comments</comments>
		<pubDate>Mon, 24 Dec 2007 10:39:54 +0000</pubDate>
		<dc:creator>Hasin Hayder</dc:creator>
		
		<category><![CDATA[orchid]]></category>

		<guid isPermaLink="false">http://orchid.phpxperts.net/2007/12/24/caching-in-orchid-is-easy/</guid>
		<description><![CDATA[Caching is one of the built in core features in orchid. Orchid supports three types of storage engine for orchid which are SQLite, MySQL and Memcache. You can take advantage of either one depending on your requirement. Lets have a look at how to work with caching engine in Orchid. 
1. Setup configuration file
if you [...]]]></description>
			<content:encoded><![CDATA[<p>Caching is one of the built in core features in orchid. Orchid supports three types of storage engine for orchid which are SQLite, MySQL and Memcache. You can take advantage of either one depending on your requirement. Lets have a look at how to work with caching engine in Orchid. </p>
<p><strong>1. Setup configuration file</strong></p>
<p>if you want SQLite as your caching storage, Use the following directives in your app/config/configs.php</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_sqlite'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbname'</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #ff0000;">&quot;sqlite.sq2&quot;</span>; 
<span style="color: #808080; font-style: italic;">//absolute path or it will be stored in app/cache</span>
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_source'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;sqlite&quot;</span>; <span style="color: #808080; font-style: italic;">//or mysql or memcache</span></pre></div></div>

<p>If you want MySQL as storage , use the following directives</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_mysql'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbname'</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_mysql'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbuser'</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_mysql'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbhost'</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_mysql'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbpass'</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_mysql'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbpersistence'</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_source'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;mysql&quot;</span>;</pre></div></div>

<p>You need to create a table named `cache` with following schema</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`cache`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`marker`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
  <span style="color: #ff0000;">`content`</span> text,
  <span style="color: #ff0000;">`valid`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
  <span style="color: #ff0000;">`modified`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`marker`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1</pre></div></div>

<p>If you use Memcache as storage, use the following directives</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_memcache'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'servers'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;host&quot;</span>=&gt;<span style="color: #ff0000;">&quot;&quot;</span>,<span style="color: #ff0000;">&quot;port&quot;</span>=&gt;<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_memcache'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'servers'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;host&quot;</span>=&gt;<span style="color: #ff0000;">&quot;&quot;</span>,<span style="color: #ff0000;">&quot;port&quot;</span>=&gt;<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
...
<span style="color: #b1b100;">as</span> many you want
&nbsp;
<span style="color: #0000ff;">$configs</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_source'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;memcache&quot;</span>;</pre></div></div>

<p><strong>2. Now take a look at the code of the controller</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000000; font-weight: bold;">class</span> cachetest <span style="color: #000000; font-weight: bold;">extends</span> controller
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> base<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">use_view</span>=<span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #0000ff;">$cache</span> = loader::<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;cache&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0000ff;">$cache</span>-&gt;<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key1&quot;</span>,<span style="color: #ff0000;">&quot;Hello World&quot;</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0000ff;">$cache</span>-&gt;<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key2&quot;</span>,<span style="color: #ff0000;">&quot;Hello World2&quot;</span>,<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000066;">sleep</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$cache</span>-&gt;<span style="color: #006600;">isExpired</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key1&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;This key has been expired after 2 seconds&quot;</span>;
&nbsp;
		<span style="color: #000066;">echo</span> <span style="color: #0000ff;">$cache</span>-&gt;<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key1&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;:&quot;</span>.<span style="color: #0000ff;">$cache</span>-&gt;<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key2&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://orchid.phpxperts.net/2007/12/24/caching-in-orchid-is-easy/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
