<?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>Promet CakePHP Source &#187; Tips &amp; Tutorials</title>
	<atom:link href="http://cakephp.prometsupport.com/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakephp.prometsupport.com</link>
	<description></description>
	<lastBuildDate>Mon, 23 Feb 2009 08:03:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>INI Based Permission Component</title>
		<link>http://cakephp.prometsupport.com/2009/ini-based-permission-component/</link>
		<comments>http://cakephp.prometsupport.com/2009/ini-based-permission-component/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 13:37:42 +0000</pubDate>
		<dc:creator>rachel</dc:creator>
				<category><![CDATA[Behaviors]]></category>
		<category><![CDATA[CakePHP 1.1]]></category>
		<category><![CDATA[CakePHP 1.2]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Helpers]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[cakePHP websites]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/?p=142</guid>
		<description><![CDATA[Yet another permission component was created this week but this time, it&#8217;s simplier and written in a text file. In one of our project, one of the follow-up requirement was to allow users of certain groups upgrade into a better status. The project was already in production and I was using ACL with Auth component [...]]]></description>
			<content:encoded><![CDATA[<p>Yet another permission component was created this week but this time, it&#8217;s simplier and written in a text file. In one of our project, one of the follow-up requirement was to allow users of certain groups upgrade into a better status. The project was already in production and I was using ACL with Auth component to do my authentication. Unfortunately, this is one of <a href="http://www.mail-archive.com/cake-php@googlegroups.com/msg57645.html">ACLs weakness</a>. </p>
<blockquote><p>Changing a users group does not change the ARO parent (effectively making it useless/impossible to change groups). I tried fixing this home-brew style, but since there&#8217;s no setParent in 1.2&#8242;s db_acl, it&#8217;s far harder than it should be.</p>
</blockquote>
<p>That was reported back in 2007 and there was still no solution found in the net. It is also not an option for me to go through the above suggestion in fixing the problem so the the other solution is to find another one or create one. I chose the latter.</p>
<p><strong>Why create a new one?</strong></p>
<p>The other solutions that I found still needs some configuration in the controllers. Since I already have a ton of files, I don&#8217;t want to go through all of them to add a line or two. I need ACLs way of doing it all in the background. Also, I am already using Auth component and I want to keep it.</p>
<p><strong>Why did I choose a text file over a database?</strong></p>
<p>My intention is to make the application faster since load time is really getting slower. Since the application isn&#8217;t that big, I only have less than 200 lines for the permissions, so a database is just overkill. Even if I use a database, I might cache it anyway so it saves me extra query.</p>
<p><strong>The component</strong></p>
<p>So Permission Component was created. Below is the instruction on how to install it.</p>
<ol>
<li><a href='http://cakephp.prometsupport.com/wp-content/uploads/2009/01/permissionphp.txt'>Download this component</a> and copy to your components folder. </li>
<li>Create cake_dir/app/config/permissions.ini</li>
</ol>
<p>The content for permissions.ini is as follows</p>
<p><code lang="ini[lines]"><br />
[ControllerName]<br />
actionName = group_id,group_id<br />
 <br />
[PluginName.ControllerName]<br />
actionName = group_id,group_id<br />
</code></p>
<p>The <em>ControllerName</em> should be the controller name itself (in camel-case format).</p>
<p>The <em>actionName</em> is also the action name itself (in camel-case format).</p>
<p>The <em>PluginName</em> is the plugin name itself (in camel-case format).</p>
<p>The <em>group_id</em> is the one written in your Auth component. Your Auth component should have a group_id value because this is what our Permission component will look for. It could be a number or set of characters.</p>
<p>Example:</p>
<p><code lang="ini[lines]"><br />
; Group ID 1 = Admin<br />
; Group ID 2 = Member<br />
[Accounts]<br />
index =<br />
add = 1<br />
edit = 1,2<br />
delete = 1,2<br />
 <br />
[ShoppingCart.Orders]<br />
index =<br />
report = 1<br />
</code></p>
<p>Assigning no group id in an actionName will simply ignore it.</p>
<p><strong>Reminder</strong></p>
<p>Use at your own risk. If you found a bug, please post them at the comment form.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2009/ini-based-permission-component/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Bake a New Project in CakePhp</title>
		<link>http://cakephp.prometsupport.com/2008/learn-how-to-bake-cakephp-app/</link>
		<comments>http://cakephp.prometsupport.com/2008/learn-how-to-bake-cakephp-app/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 13:35:50 +0000</pubDate>
		<dc:creator>rachel</dc:creator>
				<category><![CDATA[CakePHP 1.2]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[bake]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/?p=103</guid>
		<description><![CDATA[div.block {margin: .5em 25px; background-color: #efefef; padding: .5em;} div.note {margin: .5em 25px; background-color: #fffbcc; padding: .5em;} I use bake to start any project of mine and therefore doesn&#8217;t mean that using it produces a complete app unless you only want a CRUD application. This tutorial is intended for beginners in cakephp. It is still recommended [...]]]></description>
			<content:encoded><![CDATA[<style>
div.block {margin: .5em 25px; background-color: #efefef; padding: .5em;}
div.note {margin: .5em 25px; background-color: #fffbcc; padding: .5em;}
</style>
<p>I use bake to start any project of mine and therefore doesn&#8217;t mean that using it produces a complete app unless you only want a CRUD application.</p>
<p>This tutorial is intended for beginners in cakephp. It is still recommended that you look at the <a href="http://book.cakephp.org/view/219/Blog">blog tutorial</a> in cakephp manual because it has a more complete introduction for the framework. </p>
<p>Take note that I am using the <a rel="nofollow" href="http://cakeforge.org/frs/?group_id=23&#038;release_id=426">Cakephp 1.2.0.7692 RC3</a> in demonstrating this little project because it is the latest release as of this writing. </p>
<h2>What to do and what do we need to begin?</h2>
<p>To start off, we need a project. I opted a mini-library application which consists of</p>
<div class="block">Books<br />
Authors<br />
Book reviews by users
</div>
<p><span id="more-103"></span><br />
The mini-library will store different books. Each books can have one or more authors and one or more reviews created by users. So we will have the following tables</p>
<div class="block">authors<br />
books<br />
books_authors<br />
book_reviews<br />
users
</div>
<p>And they have the following relationships:</p>
<div class="block">books can have many authors<br />
authors can have many books<br />
books can have many reviews<br />
users can have many reviews<br />
a review is owned by a book
</div>
<p><a href='http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cakedemo_1.sql'>Download the SQL</a> and create your database.</p>
<h2>Let&#8217;s start baking!</h2>
<p>Since our topic is about baking, we will maximize the use of cake CLI. First, setup your environment so that it will accept the cake command. For Ubuntu users, it is already available in synaptic or use apt-get</p>
<p><code lang="bash">sudo apt-get install cakephp1.2-scripts</code></p>
<p>For windows users, I used this <a rel="nofollow" href="http://www.webdevelopment2.com/cakephp-bake-baking-models-controllers-views-cakephp-12/">tutorial for setting up Windows</a>.</p>
<div class="note">The following steps is done in Windows so I cannot guarantee the result will be the same in Ubuntu.</div>
<p>Once you have setup your environment, everything is just easy. I do not think I even need to tell you what you need to do but I still will since I already started it:P</p>
<p>You just need to remember this steps:</p>
<ol>
<li>Create a project. This creates all the files and directories under the /app directory</li>
<li>Configure database.php. We will do that using the command line</li>
<li>Start creating your Models. As the blog tutorial mentioned, models are the bread and butter of cakephp.</li>
<li>Create your controllers </li>
<li>Finally, create your views</li>
<li>Check your new app!</li>
</ol>
<p>So let&#8217;s start doing something and stop talking eh? </p>
<p>Open your command line and go to your www directory or wherever you want to create your cakephp project. Do not yet create folder for this project. So in my case, my web directory is E:\www\. Type </p>
<p><code lang="bash">cake bake </code></p>
<p>It will ask you to create your project since it cannot find an existing one. </p>
<p><b>Step 1: Create project</b><br />
I created <em>mylibrary</em> project. Here is the output.</p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake1.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake1-300x181.png" alt="CakePhp bake step 1 - Create Project" title="cake_bake1" width="300" height="181" class="size-medium wp-image-121" /></a></p>
<p><b>Step 2: Configure database</b><br />
Then it will ask you to create your database config. In my example, my database name is <em>cakedemo_1</em>.</p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake2.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake2-300x247.png" alt="CakePhp bake step 2 - Configure database" title="cake_bake2" width="300" height="247" class="size-medium wp-image-122" /></a></p>
<p>And we&#8217;re done with the installation. If you will check your files, <em>mylibrary</em> folder is created in E:\www. <em>mylibrary</em> already contains all the necessary files and folders to start building your app. To check, go to <u>http://localhost/mylibrary</u>. </p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake3.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake3-300x145.png" alt="CakePhp bake step 3 - Installation result" title="cake_bake3" width="300" height="145" class="size-medium wp-image-123" /></a></p>
<p>Do we have the same result?</p>
<p>There were 3 things that happened here in the background. </p>
<ul>
<li>In mylibrary/app/config/core.php, the Security.salt was modified</li>
<li>mylibrary/app/config/database.php was created</li>
<li>In mylibrary/app/webroot/index.php, CAKE_CORE_INCLUDE_PATH was changed to the absolute path of your cake core library, in my case &#8220;E:www\minilib&#8221; because this is what I entered in my Path settings (remember this <a rel="nofollow" href="http://www.webdevelopment2.com/cakephp-bake-baking-models-controllers-views-cakephp-12/">tutorial</a>?) So with this, you have a <strong>centralized cakephp core library</strong>.</li>
</ul>
<p>There you have it, a new cakephp project! Let&#8217;s proceed.</p>
<p><b>Step 3: Create models, controllers and views</b><br />
Next step is to create our library application. Again, type <strong>cake bake</strong> in your command line. The <strong>Interactive Bake Shell</strong> will appear to ask for more directions. You must ofcourse create first your models, then controllers and finally views. Afterwards, you should have the following files like mine:</p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake4.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake4-129x300.png" alt="CakePhp Bake Step 3 - result" title="cake_bake4" width="129" height="300" class="size-medium wp-image-127" /></a></p>
<p>If you already have that, congratulations! Your done! <img src='http://cakephp.prometsupport.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Visit the Books page in <u>http://localhost/mylibrary/books/</u> to start adding your data.</p>
<p><strong>More tricks you can try out</strong><br />
There are also shortcuts if you only want to create models<br />
<code lang="bash">cake bake model</code></p>
<p>or controllers<br />
<code lang="bash">cake bake controller</code></p>
<p>or views<br />
<code lang="bash">cake bake view</code></p>
<p>For the next post, I&#8217;ll tackle how to set up different authentication components. Till next time. Happy Baking!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/learn-how-to-bake-cakephp-app/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Learn Containable Behavior by Example</title>
		<link>http://cakephp.prometsupport.com/2008/learn-containable-behavior-by-example/</link>
		<comments>http://cakephp.prometsupport.com/2008/learn-containable-behavior-by-example/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 07:58:49 +0000</pubDate>
		<dc:creator>rachel</dc:creator>
				<category><![CDATA[Associations]]></category>
		<category><![CDATA[Behaviors]]></category>
		<category><![CDATA[CakePHP 1.2]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[containable]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/?p=44</guid>
		<description><![CDATA[In cakephp, adding relationships is easy. We just have to declare the hasOne, belongsTo, hasMany and the famous HABTM relationship to do all the dirty work of joining tables. But declaring them all at once could lead to a slow page. In version 1.1, what we do is utilize the bindModel() and unbindModel(). We do [...]]]></description>
			<content:encoded><![CDATA[<p>In cakephp, adding relationships is easy. We just have to declare the hasOne, belongsTo, hasMany and the famous HABTM relationship to do all the dirty work of joining tables. But declaring them all at once could lead to a slow page.</p>
<p>In version 1.1, what we do is utilize the <a href="http://cakephp.prometsupport.com/2008/binding-ur-models-d-easy-way/">bindModel() and unbindModel()</a>. We do not declare all associations in the Model class yet. This was a good solution. I was looking for this option in version 1.2 and I found the Containable Behavior. Studying containable was a little rough before but there are documents now that are really helpful.<br />
<span id="more-44"></span></p>
<ul>
<li><a href="http://book.cakephp.org/view/474/Containable">Cakephp Book: Containable</a></li>
<li><a href="http://cakebaker.42dh.com/2008/05/18/new-core-behavior-containable/">CakeBaker: New Core Behavior &#8211; Containable</a></li>
<li><a href="http://www.studiocanaria.com/articles/cakephp_containable_behavior">StudioCanaria: Cakephp Containable Behavior</a></li>
</ul>
<p>Today, I&#8217;ll be showing you how to use Containable in pagination and in regular find method. You must have a fair understanding of the behavior so I suggest you read the above articles first. If you are ready, follow the instructions below:</p>
<ol>
<li>Download the latest 1.2 release of cake. As of this writing, I tested it in cake_1.2.0.7296-rc2. Do the usual cake installation procedures.</li>
<li><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/09/containable_by_example.zip">Download this file</a> and unzip. It must contain an &#8220;app&#8221; folder</li>
<li>Replace the /app from #1 with the /app from #2 but leave the config file of #1.</li>
<li>Use the /app/class.sql to setup your database</li>
</ol>
<p>The idea of the sample is taken from a virtual school application. So we have Departments, Courses, Classes, Students and Teachers, Students Comments on Class and Students Ratings on Class. The following is an explanation of tables declared in class.sql so you can follow the relationships:</p>
<table style="border-collapse: collapse;" border="1" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr valign="top">
<th width="20%">TABLE</th>
<th>RELATIONSHIP</th>
</tr>
<tr valign="top">
<td>department</td>
<td>has many courses</td>
</tr>
<tr valign="top">
<td>courses</td>
<td>has many classes<br />
belongsto departments</td>
</tr>
<tr valign="top">
<td>classes</td>
<td>belongs to courses<br />
belongs to teacher<br />
has many comments<br />
has many ratings</td>
</tr>
<tr valign="top">
<td>teachers</td>
<td>has many classes</td>
</tr>
<tr valign="top">
<td>ratings</td>
<td>belongs to class<br />
belongs to student</td>
</tr>
<tr valign="top">
<td>comments</td>
<td>belongs to class<br />
belongs to student</td>
</tr>
<tr valign="top">
<td>students</td>
<td>has many comments<br />
has many ratings</td>
</tr>
</tbody>
</table>
<h2>Exampe1: List of Classes</h2>
<p>What we will do is get only the basic information for the list of classes. Those includes:</p>
<ul>
<li>Class title</li>
<li>Course it belongs to</li>
<li>Department it belongs to</li>
<li>Teacher name</li>
</ul>
<p>It will look like this (replace the http://localhost with your local address)<br />

http://localhost/cake/my_classes/index</p>

<p>Let&#8217;s compare the recursive and containable method.</p>
<p><strong>Using The Recursive Method</strong><br />
Check the MyClassesController::unfiltered_result() for your reference. First try is I added the ffg line<br />
<code lang="php">$this->MyClass->recursive = 1; </code><br />
but the problem is that I could not get the Department name. Then I tried<br />
<code lang="php">$this->MyClass->recursive = 2; </code><br />
and there I have all the information I need. The problem is that there are just to many data I do not need. Another option is to use the the paginate fields filter. Try adding this:<br />
<code lang="php">$this->paginate['MyClass']['fields'] = array( 'Course.title', 'MyClass.title' );</code></p>
<p>The result? Check it for yourself in http://localhost/cake/my_classes/unfiltered_result</p>
<p><strong>Using Containable Behavior</strong><br />
If you look at MyClassesController::index2(), you would see the ffg:<br />
<code lang="php"><br />
        $this->paginate['MyClass']['contain'] = array (<br />
            'Teacher',<br />
            'Course' => array (<br />
                'Department' => array (<br />
                    'fields' => array (<br />
                        'Department.title',<br />
                        'Department.id'<br />
                    )<br />
                )<br />
            )<br />
        );<br />
</code><br />
That basically tells cake to find the Class Teacher and return all fields, the course it belongs to and return all the fields and finally the course&#8217; Department title and ID. Now run this http://localhost/cake/my_classes/filtered_result and compare the result with the previous example. It became cleaner isn&#8217;t it?</p>
<p>With Containable, you can specify which tables to include and what fields to include each table. You can also add order and limit filters and also conditions. It took me a while to grasp the format because at first glance it is a bit difficult to follow. I use the following format:</p>
<p><code lang="php"><br />
$this->Model0->contain( array(<br />
 'Model1' => array (<br />
 'fields' 	 => array( 'modelField1', 'modelField2' ),<br />
 'conditions' => array( 'your condition here' ),<br />
 'order' 	 => array( 'id' => 'asc' ),<br />
 ),<br />
 'Model2',<br />
 'Model2'<br />
 )<br />
)<br />
</code></p>
<h2>Example2: Class View</h2>
<p>This is just to show you a more complicated containable query. We want to get more information about the class. That includes:</p>
<ul>
<li>Class title</li>
<li>Course it belongs to</li>
<li>Department it belongs to</li>
<li>Teacher name</li>
<li><strong>Student comments that were approved and student name</strong></li>
<li><strong>Student ratings that were approved and student name</strong></li>
</ul>
<p>We can achieve the desired results using recursive but then again we will be wasting so much process time. In containable, we&#8217;ll just have to declare what we want.</p>
<p><code lang="php"><br />
        $this->MyClass->contain( array(<br />
            'Teacher',<br />
            'Rating'     => array(<br />
                'Student',<br />
                'order' => array( 'created' => 'desc' ),<br />
                'conditions' => array( 'approved' => 1 )<br />
            ),<br />
            'Comment'    => array(<br />
                'Student',<br />
                'order' => array( 'RAND()' ),<br />
                'limit' => 3 ,<br />
                'conditions' => array( 'approved' => 1 )<br />
            ),<br />
            'Course'     => array(<br />
                'Department' => array(<br />
                    'fields' => array(<br />
                        'Department.title',<br />
                        'Department.id'<br />
                    )<br />
                )<br />
            )<br />
            )<br />
        );<br />
</code></p>
<p>Can you see the format now? Play around with the codes and check their results to get more comfortable with it. Happy Baking!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/learn-containable-behavior-by-example/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Use Model-&gt;create()</title>
		<link>http://cakephp.prometsupport.com/2008/use-model-create/</link>
		<comments>http://cakephp.prometsupport.com/2008/use-model-create/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 05:35:23 +0000</pubDate>
		<dc:creator>rolan</dc:creator>
				<category><![CDATA[CakePHP 1.2]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/?p=37</guid>
		<description><![CDATA[From now on, I&#8217;ll always use Model-&#62;create() before saving new data. I&#8217;ve been using Model-&#62;create() for a series Model-&#62;save() calls (like in a loop) to initialize the model class for saving new information. But when I only need to do a single call to save(), I no longer call create() assuming that I&#8217;m starting with [...]]]></description>
			<content:encoded><![CDATA[<p>From now on, I&#8217;ll always use Model-&gt;create() before saving new data.</p>
<p>I&#8217;ve been using Model-&gt;create() for a series Model-&gt;save() calls (like in a loop) to initialize the model class for saving new information. But when I only need to do a single call to save(), I no longer call create() assuming that I&#8217;m starting with a new set of information. I was always able to get away with it until I had this bug that annoyed me for a few hours.</p>
<p>Long story short, I learned something: not only when doing multiple calls to <em>Model-&gt;save()</em>, you should also call <em>Model-&gt;create()</em> before saving if a previous call to <em>Model-&gt;read()</em> was made. Or better yet, <strong>always call Model-&gt;create() whenever you are about to save new data</strong>. There are cases the previous calls to save and read made are not that obvious, like in the beforeFilter() callbacks of the controller (or the parent::beforeFilter(), like in my case).</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/use-model-create/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tip: use CakePHP Route::url() for your URLs</title>
		<link>http://cakephp.prometsupport.com/2008/tip-use-cakephp-routeurl-for-your-urls/</link>
		<comments>http://cakephp.prometsupport.com/2008/tip-use-cakephp-routeurl-for-your-urls/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 07:29:24 +0000</pubDate>
		<dc:creator>rachel</dc:creator>
				<category><![CDATA[CakePHP 1.2]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[router]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/2008/07/11/tip-use-cakephp-routeurl-for-your-urls/</guid>
		<description><![CDATA[Routing is one of the amazing features of CakePHP because it makes the urls beautiful. We use this most of the time and last time, I blogged about the helper to shortcut ones typing when using the HTML helper. Overtime, I realize how helpful it can be. Read on. Always use array when passing parameters [...]]]></description>
			<content:encoded><![CDATA[<p>Routing is one of the amazing features of CakePHP because it makes the urls beautiful. We use this most of the time and last time, I <a href="/2008/05/28/convenient-html-link/">blogged</a> about the helper to shortcut ones typing when using the HTML helper. Overtime, I realize how helpful it can be. Read on.</p>
<p>Always use array when passing parameters when creating a link or using Router::url(), it will save you time in the future. Why? Consider this scenario:</p>
<p>You created a controller <i>/users/register</i> and in your code and you added this<br />
<code lang="php"><br />
<?php echo $html->link('User Registration', '/users/register')?><br />
</code></p>
<p>Then your group or your boss decided to use a better name <i>/register</i>. Your initial thought would be to replace all those texts to those new ones, isn&#8217;t it? There is a better approach. Try the ffg:</p>
<p>In /config/router.php<br />
<code lang="php"><br />
<?php Router::connect('/register',	array('controller'=>'users','action'=>'register'));  ?><br />
</code></p>
<p>In your view:<br />
<code lang="php"><br />
<?php echo $html->link('Registration', array('controller'=>'users','action'=>'register'))?><br />
</code></p>
<p>the HTML helper uses Router::url() in its link function and the Router class magically converts array parameters to what you stated in your config.  In writing urls, we have to be consistent because it can be bad for SEO when you have too many urls pointing to the same location.</p>
<p>Although the above works beautifully but it can be a tedious job. I wrote not long ago about the <a href="/2008/05/28/convenient-html-link/">html helper</a> that could make this approach easier so you could write the ffg in your view. </p>
<p><code lang="php"><br />
<?php echo $html->link('Registration', url( 'users', 'register', null, 'teacher' ))?><br />
</code></p>
<p>It saves a few characters!</p>
<p>From the last post, I refactored it  and placed it in the bootstrap so I can call it anywhere (got that idea from the google groups). </p>
<p>Here it is:<br />
<code lang="php"><br />
    function url() {<br />
        $args = func_get_args();<br />
        $count = func_num_args();</p>
<p>        if ( $count == 1 ) {<br />
            if ( is_array( $args[0] ) ) {<br />
                $args = $args[0];<br />
                $count = count($args);<br />
            } else {<br />
                return $args[0];<br />
            }<br />
        }</p>
<p>        $short_keys = array(<br />
            0 => 'controller',<br />
            1 => 'action',<br />
            2 => 'plugin',<br />
            'c' => 'controller',<br />
            'a' => 'action',<br />
            'p' => 'plugin',<br />
        );</p>
<p>        foreach ( $short_keys as $short_name => $long_name ) {</p>
<p>            if ( isset( $args[$short_name] ) ) {<br />
                $args[$long_name] = $args[$short_name];<br />
                unset( $args[$short_name] );<br />
            }</p>
<p>        }</p>
<p>        // Need to explicitly assign plugin key<br />
        if ( !isset( $args['plugin'] ) ) $args['plugin'] = null;<br />
        if ( !isset( $args['action'] ) ) $args['action'] = 'index';<br />
        if ( !isset( $args['admin'] ) ) $args['admin'] = false;</p>
<p>        $routing = Configure::read('Routing.admin');<br />
        if ( preg_match( "/^{$routing}_/", $args['action'] ) &#038;&#038; $routing ) {<br />
            $args['admin'] = true;<br />
            $args['action'] = substr( $args['action'], strlen($routing) + 1 );<br />
        }</p>
<p>        return $args;<br />
    }<br />
</code></p>
<p>The function above could take an array OR any number of string parameters.<br />
<code lang="php"><br />
url ( 'controller', 'action', 'plugin_name', ...[more params here] )<br />
url ( array( 'c' => 'controller', 'a' => 'action', 'p' => 'plugin' ) )<br />
</code></p>
<p>The first one is strict for the first 3 parameters. The latter can be written in any order as you like. I also added support for <a href="http://www.sanisoft.com/blog/2008/04/04/the-prefix-automagic-in-cakephp-routing/">prefix routing</a> such as admin_*. So you can write:<br />
<code lang="php"><br />
url ( 'controller', 'admin_action', 'plugin_name', ...[more params here] )<br />
url ( array( 'c' => 'controller', 'a' => 'admin_action', 'p' => 'plugin' ) )<br />
</code></p>
<p><i><a href="http://api.cakephp.org/class_router.html#73cfb34ccc4dae2932041a130711ac05">Router::parse()</a></i> can also be used instead of <i>url()</i> function but the latter is faster. </p>
<p>That&#8217;s it. Happy Baking!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/tip-use-cakephp-routeurl-for-your-urls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What is compact() in controller?</title>
		<link>http://cakephp.prometsupport.com/2008/what-is-compact-in-controller/</link>
		<comments>http://cakephp.prometsupport.com/2008/what-is-compact-in-controller/#comments</comments>
		<pubDate>Fri, 23 May 2008 07:14:37 +0000</pubDate>
		<dc:creator>rachel</dc:creator>
				<category><![CDATA[CakePHP 1.2]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[compact]]></category>
		<category><![CDATA[discovery]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/2008/05/23/what-is-compact-in-controller/</guid>
		<description><![CDATA[I don&#8217;t know how much functions in php I do not know but everyday I am finding new ones specially when I started tinkering CakePHP 1.2 last week. And my latest discovery is &#8230;. compact function. After using the console script, I found this code in the controllers $users = $this->User->Teacher->find('list'); $this->set(compact('users')); compact is a [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know how much functions in php I do not know but everyday I am finding new ones specially when I started tinkering CakePHP 1.2 last week. And my latest discovery is &#8230;. compact function. After using the console script, I found this code in the controllers</p>
<p><code lang="php"><br />
$users = $this->User->Teacher->find('list');<br />
$this->set(compact('users'));</code></p>
<p><u>compact</u> is a native PHP function that creates an array containing variables and their values. <a href="http://www.littlehart.net/atthekeyboard/2007/08/07/stupid-cakephp-controller-tricks/">Chris Hartjes</a> explains it well in his blog. It&#8217;s quite neat because it will save me a few lines and spaces.</p>
<p>There you go, our new gem today: <a href="http://php.net/compact">compact()</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/what-is-compact-in-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling SQL injection in CakePHP</title>
		<link>http://cakephp.prometsupport.com/2008/handling-sql-injection-in-cakephp/</link>
		<comments>http://cakephp.prometsupport.com/2008/handling-sql-injection-in-cakephp/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 05:13:20 +0000</pubDate>
		<dc:creator>rachel</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/2008/02/11/array-conditions-is-model-functions/</guid>
		<description><![CDATA[One benefit of using a framework is that some of the most common problems we will encounter when building web applications from scratch is already taken cared of, that is if properly used. Today, we will discuss one of the most common problem we have experienced specially for beginners – SQL Injection. Let&#8217;s begin first [...]]]></description>
			<content:encoded><![CDATA[<p>One benefit of using a framework is that some of the most common problems we will encounter when building web applications from scratch is already taken cared of, that is if properly used. Today, we will discuss one of the most common problem we have experienced specially for beginners – SQL Injection.</p>
<p>Let&#8217;s begin first by defining SQL Injection.  According to <a href="http://en.wikipedia.org/wiki/SQL_injection">wikipedia</a>, <strong>SQL injection</strong> is a technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for <a href="http://en.wikipedia.org/wiki/String_literal">string literal</a> <a href="http://en.wikipedia.org/wiki/Escape_sequences">escape characters</a> embedded in <a href="http://en.wikipedia.org/wiki/SQL">SQL</a> statements or user input is not <a href="http://en.wikipedia.org/wiki/Strong_type">strongly typed</a> and thereby unexpectedly executed. It is in fact an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another.</p>
<p>To protect against SQL injection, user input must not directly be embedded in SQL statements. Instead, user input must be escaped, or parameterized statements must be used.</p>
<p>CakePHP handles this in its data abstraction layer by using mysql_real_escape_string(). To use effectively, programmers must comply to its rules. Why did I say comply? Some of model functions are very loose with what kind of parameter type to accept. This setting has caused some of the newcommers to not see the benefit of passing conditions by array. Let&#8217;s take for an example the findAll() function.</p>
<p><code lang="php"><br />
Model::findAll ( $conditions = null, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null )<br />
</code></p>
<dl>
<dt><strong>Parameters:</strong></dt>
</dl>
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td valign="top" width="4">&nbsp;</td>
<td valign="top" width="52"><em>mixed</em></td>
<td>$conditions SQL conditions as a string or as an array(&#8216;field&#8217;=&gt;&#8217;value&#8217;,&#8230;)</td>
</tr>
<tr>
<td valign="top" width="4">&nbsp;</td>
<td valign="top" width="52"><em>mixed</em></td>
<td>$fields Either a single string of a field name, or an array of 			field names</td>
</tr>
</table>
<p>The <i>$conditions</i> accepts both string and array for its passed values. Logically, only the data passed as an array will be escaped. Using arrays allows CakePHP to generate the most efficient query possible, ensure proper SQL syntax, and properly escape each individual part of the query.</p>
<p>For complex find queries, we may opt for the string condition and do all the dirty work. As of this writing, CakePHP is now offering a solution to build complex conditions using arrays.</p>
<p>Cake can parse out any valid SQL comparison operator, including match expressions using LIKE, BETWEEN, or REGEX, as long as we leave a space between the operator and the expression or value.<br />
<code lang="php">array("Post.title" => "<> This is a post")</code></p>
<p> Below is the adaptation of the IN (&#8230;)-style matches</p>
<p><code lang="php">array("Post.title" => array("First post", "Second post", "Third post"))</code></p>
<p> By default, the framework joins multiple conditions with boolean AND. To accept other boolean conditions, we could do the ffg:</p>
<p><code lang='php'>array<br />
("or" =><br />
    array<br />
    (<br />
        "Post.title" => array("First post", "Second post", "Third post"),<br />
        "Post.created" => "> " . date('Y-m-d', strtotime("-2 weeks"))<br />
    )<br />
)</code></p>
<p> Or like this:</p>
<p><code lang="php">array<br />
("Author.name" => "Bob", "or" => array<br />
    (<br />
        "Post.title" => "LIKE %magic%",<br />
        "Post.created" => "> " . date('Y-m-d', strtotime("-2 weeks")<br />
    )<br />
)</code></p>
<p>More explanation of this can be found at the <a href="http://manual.cakephp.org/chapter/models">Manual: Complex Find Conditions (using arrays)</a>.</p>
<p><i>Model::save()</i> is more strict so I did not see any problem following its rules.  If you have questions for a certain model function syntax, the <a href="http://api.cakephp.org">API</a> can be a great resource.</p>
<p>With the benefit of these Model functions, we must still have to adapt to the framework&#8217;s environment which maybe of a disadvantage at first. It will just be your choice which manners will best suit you. At the end of the day, what will matter is that the code we produce is <strong>readable</strong>,<strong> maintanable</strong> and most of all <strong>secure</strong>.</p>
<p>Source:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/SQL_injection">SQL_injection</a></li>
<li><a href="http://dev.mysql.com/tech-resources/articles/guide-to-php-security-ch3.pdf">Guid to PHP Security (PDF)</a></li>
<li><a href="http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string">mysql_real_escape_string vs addslashes</a></li>
<li><a href="http://www.sitepoint.com/forums/showthread.php?t=337881">mysql_real_escape_string vs addslashes Discussion</a></li>
<li><a href="http://manual.cakephp.org/chapter/models">CakePHP Manual: Models</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/handling-sql-injection-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using TinyMCE with CakePHP</title>
		<link>http://cakephp.prometsupport.com/2008/using-tinyce-with-cakephp/</link>
		<comments>http://cakephp.prometsupport.com/2008/using-tinyce-with-cakephp/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 15:51:40 +0000</pubDate>
		<dc:creator>cyrose</dc:creator>
				<category><![CDATA[CakePHP 1.1]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[tinymce]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/2008/01/31/17/</guid>
		<description><![CDATA[It’s finally my deadline. Oh well, I am not really a blogger so I just hope you’ll stick with my article. Please bear with my “work of art”. Duh?!? Ok, let’s get this started. As the title says, my article is all about TinyMCE + Cakephp. This may not be too challenging or may appear [...]]]></description>
			<content:encoded><![CDATA[<p>It’s finally my deadline. Oh well, I am not really a blogger so I just hope you’ll stick with my article. Please bear with my “work of art”. Duh?!?</p>
<p>Ok, let’s get this started. As the title says, my article is all about TinyMCE + Cakephp. This may not be too challenging or may appear newly baked for others but for me, it’s something worth writing for. There’s just a few blocks of information that I need to discuss and everything we’ll be done in a short while.</p>
<p>TinyMCE is a WYSIWYG editor by Moxiecode which is <a href="http://tinymce.moxiecode.com">downloadable for free</a>. It has been integrated with some of the fast-rising CMS in the OS community nowadays. Such would be joomla and drupal. Here, integrating is so easy, so just follow these steps and good luck:</p>
<ol>
<li><a href="http://tinymce.moxiecode.com/download.php">Download tinyMCE</a>.</li>
<li>Once downloaded, unpack TinyMCE, and copy just the <i>tinymce/jscripts/tiny_mce</i> folder in <i>/webroot/js</i>.</li>
<li>Then follows the configuration. To make this thing work on cakephp, simple do these:
<ol type="a">
<li>First, add the code below to the layout(s) that will be used on the page(s) that will have the editor.<br />
<code lang="javascript"><br />
<script type="text/javascript"> 
  tinyMCE.init({ 
    theme : "simple",
    mode : "textareas",
    convert_urls : false
  }); 
</script><br />
</code>
  </li>
<li>Add the javascript helper to your $helpers array in your controller(s)</li>
<li>Then, for each page that you would want the TinyMCE editor to show, just add to the top of the view file this code below:<br />
<code lang="javascript"><br />
<script type="text/javascript"> 
  tinyMCE.init({ 
    theme : "simple",
    mode : "textareas",
    convert_urls : false
  }); 
</script><br />
</code>
  </li>
</ol>
</li>
</ol>
<p>Source: <a href="http://bakery.cakephp.org/articles/view/using-tinymce-with-cakephp">Bakery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/using-tinyce-with-cakephp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CakePHP 1.2</title>
		<link>http://cakephp.prometsupport.com/2008/cakephp-12/</link>
		<comments>http://cakephp.prometsupport.com/2008/cakephp-12/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 01:04:20 +0000</pubDate>
		<dc:creator>tere</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/2008/01/30/cakephp-12/</guid>
		<description><![CDATA[The Beta version of CakePHP 1.2 has already been released. As always, newer versions are looked forward to because of the better functionality they are expected to offer with. Below is a list of some of what&#8217;s new in 1.2. 1. .ctp file view extensions 2. FormHelper for form related functions 3. Support for themes [...]]]></description>
			<content:encoded><![CDATA[<p>The Beta version of CakePHP 1.2 has already been released. As always, newer versions are looked forward to because of the better functionality they are expected to offer with.</p>
<p>Below is a list of some of what&#8217;s new in 1.2.</p>
<p>1. .ctp file view extensions<br />
2. FormHelper for form related functions<br />
3. Support for themes<br />
4. More advanced validations, caching<br />
5. Support for i18n and l10n<br />
6. Named arguments<br />
7. New core helpers (Js, Paginator, RSS, XML)<br />
8. New core classes (Set, Debugger, HttpSocket, Socket)</p>
<p>An overview of CakePHP 1.2 is presented in <a target="_blank" href="http://cakephp.prometsupport.com/wp-content/uploads/2008/01/ocphp.pdf" title="CakePHP1.2 Overview">pdf</a> that comes along with the beta version. Additionally, <a target="_blank" href="http://cakebaker.42dh.com/2007/04/05/whats-new-in-cakephp-12/" title="What's New with CakePHP 1.2?">What&#8217;s New with CakePHP 1.2?</a> lists the differences between 1.1 and 1.2.</p>
<p>Along with the new functionalities are the deprecated ones. Check out the <a target="_blank" href="http://cakebaker.42dh.com/2008/01/10/deprecated-stuff-in-cakephp-12/" title="Deprecated stuff in CakePHP 1.2">Deprecated Stuff in CakePHP 1.2</a> for a list of the deprecated items. Although these stuffs still work, they are not recommended for use anymore. They will throw notice errors when debug level is greater than 0 and are more likely to be removed on future releases.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/cakephp-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binding your Models the Easy Way</title>
		<link>http://cakephp.prometsupport.com/2008/binding-ur-models-d-easy-way/</link>
		<comments>http://cakephp.prometsupport.com/2008/binding-ur-models-d-easy-way/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 02:39:44 +0000</pubDate>
		<dc:creator>carol</dc:creator>
				<category><![CDATA[Associations]]></category>
		<category><![CDATA[CakePHP 1.1]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[bindModel]]></category>
		<category><![CDATA[unbindModel]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/2008/01/15/my-piece-of-cakefinally/</guid>
		<description><![CDATA[Finally, I&#8217;ve posted my first cakephp blog which is already a week late. So late that I really had a hard time picking a nice topic to make it worth the wait. I don&#8217;t know if this one is but I hope it&#8217;ll be helpful especially to those who are new to cake. Ive been [...]]]></description>
			<content:encoded><![CDATA[<p>    Finally, I&#8217;ve posted my first cakephp blog which is already a week late. So late that I really had a hard time picking a  nice topic to make it worth the wait.  I don&#8217;t know if this one is but I hope it&#8217;ll be helpful especially to those who are new to cake.  Ive been working on <a href="http://isupportthismessage.com">IsupportThisMessage.com</a> for almost a year and still supporting it until now since they&#8217;re planning to add more functionalities to the system. This is where I learned the basics of cake.The <a href="http://manual.cakephp.org">manual</a> is quite simple and I&#8217;ve read it over and over. But when I thought I already know a lot and started coding,  I realized, I don&#8217;t even know a bit. So really, there&#8217;s no better way of learning than actually applying it. And for almost a year, I&#8217;ve learned a lot but I must admit, I still have a lot to learn.</p>
<p>One nice thing I like about cake is the use of <a href="http://www.enode.com/x/markup/tutorial/mvc.html">MVC pattern</a> which makes my codes more organized. And I like how the querying is done which is made more simple because you wouldn&#8217;t need to declare associated tables within your query if you have already specified the associations within your model.  Fantastic!  One of the most powerful features of CakePHP is the relational       mapping provided by the model.  At first, I didn&#8217;t want to touch anything in the models coz I was confused about associations. Besides I was scared I might break the code. But when I finally understood how, I declared the necessary associations within my models most especially &#8220;messages&#8221;, coz in isupport this is often being used and it has a lot of associated tables in it. But sometimes, when you query, your association settings in the model file are giving you too much       (or not enough) information. What I mean to say is, sometimes you wouldn&#8217;t need some of the associated tables in your query result. So you have to think of a way how to minimize the result, and that is where <strong>unbindModel</strong> &amp; <strong>bindModel</strong>  model functions are used which allow you to change your association settings on the fly. But as quoted from the <a href="http://bakery.cakephp.org/articles/view/keeping-bindmodel-and-unbindmodel-out-of-your-controllers">bakery section of cakephp.org by TommyO</a>,</p>
<blockquote><p>Changing the requirements of a bind done in this way means going through your controllers and changing the bindModel call, often in multiple places. Using unbindModel in a controller also means every time a new association is added you may need to go back into your controllers and unbind the new associations in order to optimize your code.</p></blockquote>
<p>Silly, but true. Thanks to TommyO, he created a method to simplify this using the approach:</p>
<blockquote><p>binding to other Models only when needed or unbinding existing relations to minimize the size of your result set.</p></blockquote>
<p>But just an overview, you would just need to add a function within your appmodel. Then in your model class, just define your associations within an array called $assoc. You will see an example from the link. So easy huh?</p>
<p>So in your controller:</p>
<p><code><span style="color: #000000"> <span style="color: #0000bb">&lt;?php<br />
MessageController </span><span style="color: #007700">extends </span><span style="color: #0000bb">AppController </span><span style="color: #007700">{<br />
function index(</span><span style="color: #0000bb">$id</span><span style="color: #007700">) {<br />
</span><span style="color: #ff8000">// establish necessary associations<br />
</span><span style="color: #0000bb">$this</span><span style="color: #007700">-&gt;Message</span><span style="color: #0000bb"></span><span style="color: #007700">-&gt;</span><span style="color: #0000bb">expects</span><span style="color: #007700">(array(</span><span style="color: #dd0000">'Comments'</span><span style="color: #007700">, </span><span style="color: #dd0000">'User'</span><span style="color: #007700">));<br />
</span><span style="color: #0000bb"></span><span style="color: #007700"></span><span style="color: #0000bb">$results </span><span style="color: #007700">= </span><span style="color: #0000bb">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000bb">Message</span><span style="color: #007700">-&gt;</span><span style="color: #0000bb">findAll</span><span style="color: #007700">(</span><span style="color: #0000bb"></span><span style="color: #007700"></span><span style="color: #0000bb"></span><span style="color: #007700">);<br />
}<br />
}<br />
</span><span style="color: #0000bb">?&gt;</span>  </span> </code></p>
<p>Now you have it. But that&#8217;s not all. Ive read <a href="http://bakery.cakephp.org/articles/view/an-improvement-to-unbindmodel-on-model-side">another post in the bakery related to TommyO&#8217;s method</a> for model associations. In TommyO&#8217;s approach, there&#8217;s a slight difference on the way you define your model association and the models get loaded *when* you call the <i>expects()</i> function. According to Mariano, the author of the post, he said he&#8217;s not a fan of changing how things are done in cakephp, neither do I. His approach is to use the Cakephp way of defining associations in the models and then specify which relations he&#8217;s interested in getting back when querying a model. This way, models behave the way models are supposed to. The main idea here is that you define your associations in the model the cakephp way. Then in your controller, if you want the standard result cakephp brings then you don&#8217;t need to call <i>expects()</i> (With TommyO&#8217;s approach, you will need to call <i>expects()</i>  with all the necessary values). Use <i>expects()</i>, only when you want to limit the result of your query. And if you want to unbindAll just call <i>expects()</i> with no parameters. You will need to add three functions in your appmodel which you will find <a href="http://bakery.cakephp.org/articles/view/an-improvement-to-unbindmodel-on-model-side">here</a>. There are additional topics included here like &#8220;<em>making multiple expects in one call</em>&#8220;. And if I&#8217;m a little confusing in explaining, I think you can understand it better when you visit the links. hehehehe.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/binding-ur-models-d-easy-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
