OT: CodeIgniter Routing

Eric Cope eric.cope at gmail.com
Fri Nov 30 11:12:54 MST 2012


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.
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.

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.

Does that help?

Eric


On Fri, Nov 30, 2012 at 11:04 AM, keith smith <klsmith2020 at yahoo.com> wrote:

>
> 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"?
>
> 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.
>
> Any thoughts?
>
> I not finding much in the way of what the CI style of development is.
>
> ------------------------
> Keith Smith
>
> --- On *Fri, 11/30/12, Eric Cope <eric.cope at gmail.com>* wrote:
>
>
> From: Eric Cope <eric.cope at gmail.com>
>
> Subject: Re: OT: CodeIgniter Routing
> To: "Main PLUG discussion list" <plug-discuss at lists.phxlinux.org>
> Date: Friday, November 30, 2012, 10:47 AM
>
>
> 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.
>
> Eric
>
>
> On Fri, Nov 30, 2012 at 10:33 AM, keith smith <klsmith2020 at yahoo.com<http://mc/compose?to=klsmith2020@yahoo.com>
> > wrote:
>
>
> If I can avoid modifying the routing.php script that would be great.
>
> 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.
>
> I have not found any real in-dept info on CI routing.
>
> Thanks for your help!!
>
> ------------------------
> Keith Smith
>
> --- On *Fri, 11/30/12, Tom Haws <tom.haws at gmail.com<http://mc/compose?to=tom.haws@gmail.com>
> >* wrote:
>
>
> From: Tom Haws <tom.haws at gmail.com<http://mc/compose?to=tom.haws@gmail.com>
> >
>
> Subject: Re: OT: CodeIgniter Routing
> To: "Main PLUG discussion list" <plug-discuss at lists.phxlinux.org<http://mc/compose?to=plug-discuss@lists.phxlinux.org>
> >
> Date: Friday, November 30, 2012, 9:53 AM
>
>
> 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.
>
> 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.
>
> --
> "To forgive is the highest, most beautiful form of love. In return, you
> will receive untold peace and happiness." - Dr. Robert Muller
>
>
> On Fri, Nov 30, 2012 at 9:36 AM, Eric Cope <eric.cope at gmail.com<http://mc/compose?to=eric.cope@gmail.com>
> > wrote:
>
> You can just put your controller "pages" in the controller/cp directory...
>
> Then you don't have to muck with the routes...
>
> Eric
>
>
> On Fri, Nov 30, 2012 at 9:20 AM, keith smith <klsmith2020 at yahoo.com<http://mc/compose?to=klsmith2020@yahoo.com>
> > wrote:
>
>
>
> Hi,
>
> 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.
>
> 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)
>
> I was thinking I needed to configure the controllers this way
>
> 1) $route['cp/pages/(:any)'] = "cp_pages"; (would contain only controller
> code for managing the pages table.)
>
> 2) $route['cp/users/(:any)'] = "cp_users"; (would contain only controller
> code for managing the users table.)
>
> .... other table configured with their own control panel.
>
> 3) $route['cp/'] = "cp"; (splash page and menu.  If not logged in presents
> the log in form)
>
> /cp/  gives me the splash page. so far so good.
>
> /cp/pages - cp controller - not what I was expecting.  I was wanting the
> index function of the cp_pages controler.
>
> /cp/pages/list/ - takes me to the cp_pages controller / index function
>
> What I would like to configure is:
>
> /cp/ - use cp controller
>
> /cp/pages/ - use the cp_pages controller / index function
> /cp/pages/add/ - use the cp_pages controller / add function
> /cp/pages/list - use the cp_pages controller /list function
> /cp/pages/list/10 - use the cp_pages controller /list function with
> segment set to 10 as starting point.
>
> If I'm going down the wrong path please let me know.
>
> Thank you!
>
>
> ------------------------
> Keith Smith
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org<http://mc/compose?to=PLUG-discuss@lists.phxlinux.org>
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org<http://mc/compose?to=PLUG-discuss@lists.phxlinux.org>
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
>
>
> -----Inline Attachment Follows-----
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org<http://mc/compose?to=PLUG-discuss@lists.phxlinux.org>
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org<http://mc/compose?to=PLUG-discuss@lists.phxlinux.org>
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
>
>
> -----Inline Attachment Follows-----
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org<http://mc/compose?to=PLUG-discuss@lists.phxlinux.org>
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20121130/74f7ba1f/attachment.html>


More information about the PLUG-discuss mailing list