You should use the singular form when referencing your model in code -
only your controller and table name should be plural.
class Business extends AppModel {
var $name = 'Business';
}
class StartsController extends AppController {
var $name = 'Starts';
var $uses = array('Business', 'Tag');
var $helpers = array('Html');
function index() {
$this->set('businesses', $this->Business->find('all',
array('limit' => 10)));
$this->set('tags', $this->Tag->find('all', array('limit' =>
10)));
}
}
On Sep 4, 11:41 am, powtac <[EMAIL PROTECTED]> wrote:
> Hi,
> I have an static controller, which should just act as wrapper for two
> other controllers:
>
> <?php
> class StartsController extends AppController {
>
> var $name = 'Starts';
> var $uses = array('Businesses', 'Tags');
> var $helpers = array('Html');
>
> function index() {
> $this->set('businesses', $this->Businesses->find('all',
> array('limit' => 10)));
> $this->set('tags', $this->Tags->find('all', array('limit' =>
> 10)));
> }
>
> }
>
> ?>
>
> In my view I get the following array as result for debug($businesses):
>
> Array
> (
> [0] => Array
> (
> [Businesses] => Array
> (
> [id] => 1
> [title] => asdf
> [description] => asdf
> )
>
> )
>
> [1] => Array
> (
> [Businesses] => Array
> (
> [id] => 2
> [title] => asd fa s
> [description] => dfa df
> )
>
> )
>
> The problem:
> The key in the result-array is plural not singular! "Businesses"
> instead of "Business". How can I get the result I the normal format?
>
> Thank you for your help,
> Simon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---