also make sure to XSS clean the table names if you are planning on passing them in from the URL.<div><br></div><div>Eric</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 30, 2012 at 2:07 PM, Tom Haws <span dir="ltr"><<a href="mailto:tom.haws@gmail.com" target="_blank">tom.haws@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In other words, wouldn't you have the model functions build the data arrays the way the views are going to need them, then call that output from the controllers and send it to the views?<div class="gmail_extra">

<div class="im"><br clear="all">
--<br>"To forgive is the highest, most beautiful form of love. In return, you will receive untold peace and happiness." - Dr. Robert Muller<br>
<br><br></div><div><div class="h5"><div class="gmail_quote">On Fri, Nov 30, 2012 at 2:00 PM, Tom Haws <span dir="ltr"><<a href="mailto:tom.haws@gmail.com" target="_blank">tom.haws@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>Keith,</div><div> </div><div>What I'm maybe not understanding is why you are putting 100 lines of CRUD into the controllers.  We have all CRUD functions in the models, and we simply call them in the controller functions, so that they typically are much shorter than 100 lines.</div>



<div> </div><div>So what I would expect is 100 model files and one controller file with a function each for 100 pages, assuming you want to organize it that way.  I think another way might be to make /cp a module with each cp/page1 cp/page2, etc a controller file with mainly only an index function in it.  </div>



<div> </div><div>Tom</div><div>Gilbert</div><div class="gmail_extra"><div><br clear="all">--<br>"To forgive is the highest, most beautiful form of love. In return, you will receive untold peace and happiness." - Dr. Robert Muller<br>




<br><br></div><div><div><div class="gmail_quote">On Fri, Nov 30, 2012 at 1:41 PM, keith smith <span dir="ltr"><<a href="mailto:klsmith2020@yahoo.com" target="_blank">klsmith2020@yahoo.com</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="font:inherit;font-size-adjust:inherit;font-stretch:inherit" valign="top"><br>Thank Tom,<br><br>I'm already following the M-V-C like you outlined.  The database is normalized so no tables can be combined.<br>



<br>For one table the controller contains about 100 lines of code for add/edit/delete/save/list.  For 50 tables that would be 5000 lines of code in one controller.<br><br>If I can figure out the routing, I can create one controller per table.  That is the optimum for me.  Otherwise I will use includes with a switch to determine what code needs to be included and run.<br>



<br>Thanks again!!<div><br><br><br><br>------------------------<br>
Keith Smith<br><br>--- On <b>Fri, 11/30/12, Tom Haws <i><<a href="mailto:tom.haws@gmail.com" target="_blank">tom.haws@gmail.com</a>></i></b> wrote:<br></div><blockquote style="padding-left:5px;margin-left:5px;border-left-color:rgb(16,16,255);border-left-width:2px;border-left-style:solid">



<div><br>From: Tom Haws <<a href="mailto:tom.haws@gmail.com" target="_blank">tom.haws@gmail.com</a>><br>Subject: Re: OT: CodeIgniter Routing<br>To: "Main PLUG discussion list" <<a href="mailto:plug-discuss@lists.phxlinux.org" target="_blank">plug-discuss@lists.phxlinux.org</a>><br>



</div>Date: Friday, November 30, 2012, 12:13 PM<div><div><br><br><div><div>Keith,</div><div> </div><div>Remember the MVC motto "Keep models fat.  Keep controllers skinny."  Ideally the controller is nothing but a butler or a receptionist who knows who does what and where to send you for what.</div>




<div> </div><div>Here's what would be the standard procedure for the Tempe, Arizona Valley MedTrans team.</div><div> </div><div>1.  For every cp/, cp/page1, cp/page2, etc, have a function index(), function page1() function page2(), etc in controllers/cp.php.</div>




<div>2.  For every table (or logical "item" of business) such as article, user_account, inventory_item, bid, shipment, etc, have a file models/article_model.php, models/user_account_model.php, models/inventory_item_model.php, models/bid_model.php, models/shipment_model.php.</div>




<div>3.  Inside every _______model.php file, have functions like get_user_account($id), change_user_password($user_id, $new_password), get_shipments_by_user($user_id).</div><div> </div><div>Is it possible some of your tables might be able to be combined?  Would you be interested in sharing part of the db schema?</div>




<div><br clear="all">--<br>"To forgive is the highest, most beautiful form of love. In return, you will receive untold peace and happiness." - Dr. Robert Muller<br>
<br><br><div>On Fri, Nov 30, 2012 at 11:20 AM, keith smith <span dir="ltr"><<a href="http://mc/compose?to=klsmith2020@yahoo.com" rel="nofollow" target="_blank">klsmith2020@yahoo.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">




<table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="font:inherit;font-size-adjust:inherit;font-stretch:inherit" valign="top"><br>Ok,  I understand.  What you are talking about is what I would like to do.  However When I drop cp.php in the controllers directory and drop pages.php in the controllers/cp directory,<br>




<br>/cp/pages uses the cp.php controller.  If this is what you suggested earlier, I must have it mis configured.<br><br>I appreciate your help!!<br><br>------------------------<br>
Keith Smith<br><div><br>--- On <b>Fri, 11/30/12, Eric Cope <i><<a href="http://mc/compose?to=eric.cope@gmail.com" rel="nofollow" target="_blank">eric.cope@gmail.com</a>></i></b> wrote:<br></div><blockquote style="padding-left:5px;margin-left:5px;border-left-color:rgb(16,16,255);border-left-width:2px;border-left-style:solid">




<div><br>From: Eric Cope <<a href="http://mc/compose?to=eric.cope@gmail.com" rel="nofollow" target="_blank">eric.cope@gmail.com</a>><br>Subject: Re: OT: CodeIgniter Routing<br>To: "Main PLUG discussion list" <<a href="http://mc/compose?to=plug-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">plug-discuss@lists.phxlinux.org</a>><br>




</div>Date: Friday, November 30, 2012, 11:12 AM<div><div><br><br><div>You can do it that way. I always found that the CRUD wasn't just a simple CRUD. The form validation was slightly different. The data manipulation between models and views was slightly different. <div>




Therefore, I built individual controllers, with a database table having its own model extended from MY_Model extended from CI_Model. This allowed me to put all of the common model functions in one file, test it, then extend it further for other additional functionality.</div>






<div><br></div><div>The CI style is less about doing it a specific way. Its not like Rails where there is ONLY one way to do things. CI is flexible.</div><div><br></div><div>Does that help?</div><div><br></div><div>Eric</div>






<div><br><br><div>On Fri, Nov 30, 2012 at 11:04 AM, keith smith <span dir="ltr"><<a href="http://mc/compose?to=klsmith2020@yahoo.com" rel="nofollow" target="_blank">klsmith2020@yahoo.com</a>></span> wrote:<br>

<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="font:inherit;font-size-adjust:inherit;font-stretch:inherit" valign="top">




<br>Actually I have 50+ tables to deal with.  That number will grow.  I'm not following what you are suggesting - "abstracting the models into a MY_Model.php core file"?  <br>

<br>I'm thinking one controller for the control panel, and depending on what the second segment is (second segment is the table name) then pull in the code for managing the one table.  That way I have one controller and 50 includes that each contain the CRUD for it's own table.<br>






<br>Any thoughts?<br><br>I not finding much in the way of what the CI style of development is.  <br><br>------------------------<br>
Keith Smith<br><div><br>--- On <b>Fri, 11/30/12, Eric Cope <i><<a href="http://mc/compose?to=eric.cope@gmail.com" rel="nofollow" target="_blank">eric.cope@gmail.com</a>></i></b> wrote:<br></div><blockquote style="padding-left:5px;margin-left:5px;border-left-color:rgb(16,16,255);border-left-width:2px;border-left-style:solid">






<br>From: Eric Cope <<a href="http://mc/compose?to=eric.cope@gmail.com" rel="nofollow" target="_blank">eric.cope@gmail.com</a>><div><br>Subject: Re: OT: CodeIgniter Routing<br>To: "Main PLUG discussion list" <<a href="http://mc/compose?to=plug-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">plug-discuss@lists.phxlinux.org</a>><br>






</div>Date: Friday, November 30, 2012, 10:47 AM<div><div><br><br><div>if you are adding 30+ controllers just for CRUD, think about abstracting the models into a MY_Model.php core file. Keep it DRY, it makes testing easier too.<div>






<br></div><div>Eric</div><div><br><br><div>

On Fri, Nov 30, 2012 at 10:33 AM, keith smith <span dir="ltr"><<a href="http://mc/compose?to=klsmith2020@yahoo.com" rel="nofollow" target="_blank">klsmith2020@yahoo.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">








<table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="font:inherit;font-size-adjust:inherit;font-stretch:inherit" valign="top"><br>If I can avoid modifying the routing.php script that would be great.  <br>




<br>I watched both video's that were on the old CI site, read lots of posts on Google, and have a book that I read cover to cover.  <br>



<br>I have not found any real in-dept info on CI routing.<br><br>Thanks for your help!!  <br><br>------------------------<br>
Keith Smith<br><br>--- On <b>Fri, 11/30/12, Tom Haws <i><<a href="http://mc/compose?to=tom.haws@gmail.com" rel="nofollow" target="_blank">tom.haws@gmail.com</a>></i></b> wrote:<br><blockquote style="padding-left:5px;margin-left:5px;border-left-color:rgb(16,16,255);border-left-width:2px;border-left-style:solid">








<br>From: Tom Haws <<a href="http://mc/compose?to=tom.haws@gmail.com" rel="nofollow" target="_blank">tom.haws@gmail.com</a>><div><br>Subject: Re: OT: CodeIgniter Routing<br></div>To: "Main PLUG discussion list" <<a href="http://mc/compose?to=plug-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">plug-discuss@lists.phxlinux.org</a>><br>








Date: Friday, November 30, 2012, 9:53 AM<div><div><br><br><div>Yeah.  Keep researching CodeIgniter tutorials, because ideally, you wouldn't ever need to use routes.php unless you had a need for an alias or some other special occasion.<br>








<br>On another note, it would be more conventional to talk to your database tables in model files and then call model functions in your controllers.  Again, I recall watching a short CodeIgniter tutorial video that really helped clarify this.<br>









<div><br clear="all">--<br>"To forgive is the highest, most beautiful form of love. In return, you will receive untold peace and happiness." - Dr. Robert Muller<br>
<br><br><div>On Fri, Nov 30, 2012 at 9:36 AM, Eric Cope <span dir="ltr"><<a href="http://mc/compose?to=eric.cope@gmail.com" rel="nofollow" target="_blank">eric.cope@gmail.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">









You can just put your controller "pages" in the controller/cp directory...<div><br></div><div>Then you don't have to muck with the routes...</div><div><br></div><div>Eric</div><div><br><br>


<div><div><div>On Fri, Nov 30, 2012 at 9:20 AM, keith smith <span dir="ltr"><<a href="http://mc/compose?to=klsmith2020@yahoo.com" rel="nofollow" target="_blank">klsmith2020@yahoo.com</a>></span> wrote:<br></div></div>









<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div>

<table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="font:inherit;font-size-adjust:inherit;font-stretch:inherit" valign="top"><br><br>Hi,<br><br>I'm rather new to CodeIgniter.  I'm using version 2.0.3 and am using the provided .htaccess code to remove index.php from the URL.  <br>











<br>I'm working on a control panel and would like to set up a controller for each table to keep things simple and modular.  (any feedback on a better idea is much appreciated)<br><br>I was thinking I needed to configure the controllers this way<br>











<br>1) $route['cp/pages/(:any)'] = "cp_pages"; (would contain only controller code for managing the pages table.)<br><br>2) $route['cp/users/(:any)'] = "cp_users"; (would contain only controller code for managing the users table.)<br>











<br>.... other table configured with their own control panel.<br><br>3) $route['cp/'] = "cp"; (splash page and menu.  If not logged in presents the log in form)<br><br>/cp/  gives me the splash page. so far so
 good.<br><br>/cp/pages - cp controller - not what I was expecting.  I was wanting the index function of the cp_pages controler.<br><br>/cp/pages/list/ - takes me to the cp_pages controller / index function<br><br>What I would like to configure is:<br>











<br>/cp/ - use cp controller<br><br>/cp/pages/ - use the cp_pages controller / index function<br>/cp/pages/add/ - use the cp_pages controller / add function <br>/cp/pages/list - use the cp_pages controller /list function<br>











/cp/pages/list/10 - use the cp_pages controller /list function with segment set to 10 as starting point.<br><br>If I'm going down the wrong path please let me know.<br><br>Thank you!  <br><br><br>------------------------<br>












Keith Smith</td></tr></tbody></table><br></div></div>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>
<br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>
</div><br></div></div>-----Inline Attachment Follows-----<div><br><br><div>---------------------------------------------------<br>PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>








To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div>






</div></blockquote>

</td></tr></tbody></table><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>
</div><br>-----Inline Attachment Follows-----<br><br><div>---------------------------------------------------<br>PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>






To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div>




</div></div>

</blockquote></td></tr></tbody></table><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>
</div><br>-----Inline Attachment Follows-----<br><br><div>---------------------------------------------------<br>PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>




To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div>



</div></div>
</blockquote></td></tr></tbody></table><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" rel="nofollow" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="nofollow" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>
</div><br>-----Inline Attachment Follows-----<br><br><div>---------------------------------------------------<br>PLUG-discuss mailing list - <a href="http://mc/compose?to=PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>



To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></div></div>



</blockquote></td></tr></tbody></table><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
<br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>