of my latest reply. :)
On Nov 28, 11:49 am, Kerr <hayl...@gmail.com> wrote:
> I noted in my initial post that I'd tried $useTable to no avail,
> though I did not
>
> I don't see in the API where $uses is a valid option in this scenario,
> however I do see $useTable.
>
> http://api.cakephp.org/class/model
>
> Looking at the source of /cake/libs/model.php, I see that $useTable is
> declared as a string on line 55 (using 1.2.5), and so I'd believe that
> John's recomendation, which is what I tried to begin with, would work
> fine. Regardless, it does not. I'm able to use scaffolding with the
> table named as "invoicestatuses", though Cake seems to ignore if I try
> to force the table name to "invoice_statuses" like so:
>
> var $useTable = 'invoice_statuses';
>
> ..
>
> On Nov 28, 11:13 am, Dave <davidcr...@gmail.com> wrote:
>
> > its actually var $uses = array('TABLENAME');
>
> > On Sat, Nov 28, 2009 at 9:53 AM, John Andersen <j.andersen...@gmail.com>wrote:
>
> > > Try specifying the tables name using:
>
> > > var $useTable = 'your tablename';
>
> > > Enjoy,
> > > John
>
> > > On Nov 28, 3:26 pm, Kerr <hayl...@gmail.com> wrote:
> > > > @John
>
> > > > * When the table is named invoice_statuses, the error message reads,
> > > > "Error: Database table invoicestatuses for model Invoicestatus was
> > > > not found."
>
> > > > * When the table is named invoicestatuses, the error message reads,
> > > > "Error: Database table invoice_statuses for model InvoiceStatus was
> > > > not found."
>
> > > > So as you can see, it's a catch-22 as when I name the table one way,
> > > > it looks for the other and vice versa.
>
> > > > Note that I'm using ACL and hadn't added any ACOs as I didn't have
> > > > methods yet in my controller. I also didn't have any beforefilter in
> > > > my controller to allow any actions, bypassing Auth. The issue was
> > > > fixed when I added the following:
>
> > > > function beforeFilter() {
> > > > parent::beforeFilter();
> > > > $this->Auth->allowedActions = array('*');
>
> > > > }
>
> > > > This worked fine with the table named as "invoicestatuses", which was
> > > > its initial name. While I'm glad I can now use scaffolding, I'm
> > > > unclear as to why this error message appears and is related to the
> > > > above Auth fix. The model itself is simple, and since you asked here
> > > > is that code:
>
> > > > class InvoiceStatus extends AppModel {
> > > > var $name = 'InvoiceStatus';
> > > > var $hasMany = array(
> > > > 'Invoice'
> > > > );
> > > > var $validate = array(
> > > > 'name' => array('notempty')
> > > > );
>
> > > > }
>
> > > > @Dave - This is not a HABTM scenario, rather a simple lookup table
> > > > with name and ID key pairs.
>
> > > > On Nov 27, 5:04 pm, Dave <davidcr...@gmail.com> wrote:
>
> > > > > It sounds like you are trying to create a HABTM join table, if so, I
> > > > > recommend reading the manual on how to do this through CakePHP. There
> > > > > should be no need to actually create a model for this table, and cake
> > > will
> > > > > handle all of the relationships for you =)
>
> > > > >http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM
>
> > > > > <http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM>
>
> > > > > On Fri, Nov 27, 2009 at 6:40 AM, John Andersen <
> > > j.andersen...@gmail.com>wrote:
>
> > > > > > Which table does CakePHP say it can't find? Is it "invoices_statuses"
> > > > > > or "invoice_statusses"?
> > > > > > Show the error and maybe also the model definition!
> > > > > > Enjoy,
> > > > > > John
>
> > > > > > On Nov 25, 3:12 pm, Kerr <hayl...@gmail.com> wrote:
> > > > > > > Hi folks, I'm using CakePHP for a new project, and I am having a
> > > great
> > > > > > > time not having to do so much CRUD work! That said, I want to set
> > > up
> > > > > > > a simple $scaffold based model, and I'm having trouble reconciling
> > > a
> > > > > > > table to a model. My application handles client billing for a
> > > > > > > business, and I have a model named Invoice, with all the convention
> > > > > > > based names for tables, columns, controllers, etc. Invoices must
> > > > > > > carry a status, and here is where I'm having some trouble. Here is
> > > > > > > the layout of the assets in question:
>
> > > > > > > Table name: invoicestatuses (OR invoice_statuses)
> > > > > > > Model name: InvoiceStatus
> > > > > > > Model file name: invoice_status.php
> > > > > > > Controller name: InvoiceStatusesController
> > > > > > > Controller file name: invoicestatuses_controller.php
>
> > > > > > > CakePHP is able to find my model and controller, but it chokes on
> > > > > > > locating the table. If I use the former table name, CakePHP throws
> > > an
> > > > > > > error saying it can't find the latter, and vice versa. I've tried
> > > > > > > hardcoding either table in my model using the $table variable, and
> > > > > > > even $useTable (not sure if that would generally work anyway), but
> > > > > > > CakePHP always comes back telling me it can't find the table for my
> > > > > > > model.
>
> > > > > > > What am I doing wrong here?
>
> > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > > others
> > > > > > with their CakePHP related questions.
>
> > > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > > "CakePHP" group.
> > > > > > To post to this group, send email to cake-php@googlegroups.com
> > > > > > To unsubscribe from this group, send email to
> > > > > > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.com>
> > > <cake-php%2Bunsubscribe@googlegroups.com<cake-php%252Bunsubscribe@googlegroups.com>>For
> > > more options, visit this group at
> > > > > >http://groups.google.com/group/cake-php?hl=en
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others
> > > with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups
> > > "CakePHP" group.
> > > To post to this group, send email to cake-php@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> > >http://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment