<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><br>I want to create separate CRUD controllers for each table. If I use one controller to manage 30 or 40 tables I end up with a controller that would be thousands of lines long. <br><br>I am following the M-V-C methodology built into Codeigniter.<br><br>I'm trying to figure out how to build the routing so that I can have :<br><br>/cp - menu and login<br><br>/cp/pages - CRUD controller for the pages table<br><br>/cp/users - CRUD controller for the users table<br><br>I will need to CRUD 30+ tables. <br><br>Thank you for your help!<br> <br><br>------------------------<br>
Keith Smith<br><br>--- On <b>Fri, 11/30/12, Amit Nepal <i><amit@amitnepal.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Amit Nepal <amit@amitnepal.com><br>Subject: Re: OT: CodeIgniter Routing<br>To: plug-discuss@lists.phxlinux.org<br>Date: Friday, November 30, 2012, 10:06 AM<br><br><div id="yiv222297425">
<div>
<div class="yiv222297425moz-cite-prefix">I avoid routes as much as possible.
Controller alone can handle various functions and you don't really
need to create multiple controllers for similar task. Helps keep
it simple. <br>
<br>
eg. if I were to have CRUD operations on a page, i would create a
page controller , which would then have various functions like
add , delete, update etc and the default (index) function in the
controller would list stuffs.<br>
<br>
For database as Tom metioned, just use the model (eg.
page_model.php , would have all the functions related to database
) , you can then load page model in the page controller and do
the CRUD operations.<br>
<br>
<a rel="nofollow" class="yiv222297425moz-txt-link-freetext" target="_blank" href="http://tutorialcodeigniter.com/beginners/welcome.html">http://tutorialcodeigniter.com/beginners/welcome.html</a> ( This
might be helpful too)<br>
<br>
<br>
<div class="yiv222297425moz-signature"><b>Amit K Nepal<br>
Infrastructure Engineer (RHCE)<br>
<a rel="nofollow" target="_blank" href="http://www.omnovia.com">omNovia Technologies Inc</a><br>
<a rel="nofollow" target="_blank" href="http://www.amitnepal.com">Amit K Nepal</a><a rel="nofollow" target="_blank" href="http://www.amitnepal.com"><br>
</a></b></div>
On 11/30/2012 9:53 AM, Tom Haws wrote:<br>
</div>
<blockquote type="cite">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 class="yiv222297425gmail_extra"><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 class="yiv222297425gmail_quote">On Fri, Nov 30, 2012 at 9:36 AM, Eric
Cope <span dir="ltr"><<a rel="nofollow" ymailto="mailto:eric.cope@gmail.com" target="_blank" href="/mc/compose?to=eric.cope@gmail.com">eric.cope@gmail.com</a>></span>
wrote:<br>
<blockquote class="yiv222297425gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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 class="yiv222297425gmail_extra"><br>
<br>
<div class="yiv222297425gmail_quote">
<div>
<div class="yiv222297425h5">On Fri, Nov 30, 2012 at 9:20 AM, keith
smith <span dir="ltr"><<a rel="nofollow" ymailto="mailto:klsmith2020@yahoo.com" target="_blank" href="/mc/compose?to=klsmith2020@yahoo.com">klsmith2020@yahoo.com</a>></span>
wrote:<br>
</div>
</div>
<blockquote class="yiv222297425gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>
<div class="yiv222297425h5">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font: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 rel="nofollow" ymailto="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" href="/mc/compose?to=PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail
settings:<br>
<a rel="nofollow" target="_blank" href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br>
</blockquote>
</div>
<br>
</div>
<br>
---------------------------------------------------<br>
PLUG-discuss mailing list - <a rel="nofollow" ymailto="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" href="/mc/compose?to=PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a rel="nofollow" target="_blank" href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="yiv222297425mimeAttachmentHeader"></fieldset>
<br>
<pre>---------------------------------------------------
PLUG-discuss mailing list - <a rel="nofollow" class="yiv222297425moz-txt-link-abbreviated" ymailto="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" href="/mc/compose?to=PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a>
To subscribe, unsubscribe, or to change your mail settings:
<a rel="nofollow" class="yiv222297425moz-txt-link-freetext" target="_blank" href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></pre>
</blockquote>
<br>
</div>
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">---------------------------------------------------<br>PLUG-discuss mailing list - <a ymailto="mailto:PLUG-discuss@lists.phxlinux.org" href="/mc/compose?to=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></div></blockquote></td></tr></table>