The SQL Query generated doesn't have a join:
*Warning* (512) <javascript:void(0);>: *SQL Error:* 1054: Unknown
column 'Count.count' in 'order clause'
[*CORE\cake\libs\model\datasources\dbo_source.php*, line *673*]
Code <javascript:void(0);> | Context <javascript:void(0);>
$out = null; if ($error) {
trigger_error('<span style="color:Red;text-align:left"><b>' . __('SQL
Error:', true) . "</b> {$this->error}</span>", E_USER_WARNING);
$sql = "SELECT `Place`.`id`, `Place`.`name`, `Place`.`guy_count` FROM
`places` AS `Place` WHERE 1 = 1 ORDER BY `Count`.`count` ASC "
$error = "1054: Unknown column 'Count.count' in 'order clause'"
$out = null
DboSource::showQuery() -
CORE\cake\libs\model\datasources\dbo_source.php, line 673
DboSource::execute() - CORE\cake\libs\model\datasources\dbo_source.php, line 263
DboSource::fetchAll() -
CORE\cake\libs\model\datasources\dbo_source.php, line 407
DboSource::read() - CORE\cake\libs\model\datasources\dbo_source.php, line 812
Model::find() - CORE\cake\libs\model\model.php, line 2090
PlacesController::index() - APP\controllers\places_controller.php, line 16
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 83
*Query:* SELECT `Place`.`id`, `Place`.`name`, `Place`.`guy_count` FROM
`places` AS `Place` WHERE 1 = 1 ORDER BY `Count`.`count` ASC
On Wed, Aug 18, 2010 at 8:59 PM, bradmaxs <[email protected]> wrote:
> What fields do you have in the Count table? When I get this error it
> is because the join was incorrect - usually. Also - when the errors
> occur, usually there is a code and a context link that will show you
> more of the dump when clicked on and what the conflicting code is. It
> should have also printed out the sql query at the top and you can see
> the exact query and troubleshoot from there.
>
> On Aug 17, 6:07 am, Okalany Daniel <[email protected]> wrote:
> > the model Place hasMany Count, and Count belongs to place.
> > So using the Containable behaviour, i can specify conditions for child
> > fields like:
> >
> > $this->Place->Behaviors->attach('Containable');
> > $this->paginate['Place'] = array(
> > 'contain' => array('Count'=>array(
> > 'conditions'=>array('Count.date'=>date('Y-m-d'))
> > )),
> > //'order' => 'Count.count DESC'
> > );
> > $places = $this->paginate('Place');
> >
> > But i'd like to order the parent Model by a field in a child model. When
> i
> > uncomment the line that starts 'order', i get the error:
> > SQL Error: 1054: Unknown column 'Count.count' in 'order clause'
> >
> > Thanks in advance.
> >
> >
> >
> >
> >
> > On Tue, Aug 17, 2010 at 10:28 AM, AD7six <[email protected]> wrote:
> >
> > > On Aug 16, 5:25 pm, Okalany Daniel <[email protected]> wrote:
> > > > Hi, Andy Dawson,
> > > > i'm having a similar problem,
> >
> > > How similar is your sql error or code ? I find it hard to compare to
> > > things I can't see :).
> >
> > > > but i don't understand your fix.
> >
> > > I didn't get as far as to propose a fix. However I'll give you this
> > > hint: the book almost certainly has a relevant example and hasMany/
> > > hasAndBelongsToMany don't generate joins in the main query - hasOnes
> > > do.
> >
> > > AD
> >
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<cake-php%[email protected]>
> <cake-php%[email protected] om>For more options, visit this
> group at
> > >http://groups.google.com/group/cake-php?hl=en
> >
> > --
> > OKALANY DANIEL,
> > P.O BOX 26150,
> > Kampala.,
> > Uganda.http://okasoft.net
> > --
> > When confronted by our worst nightmares, the choices are few; Fight or
> > flight. We hope to find the strength to stand against our fears but
> > sometimes, despite ourselves, we run. What if the nightmare gives chase?
> > Where can we hide then?
>
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
--
OKALANY DANIEL,
P.O BOX 26150,
Kampala.,
Uganda.
http://okasoft.net
--
When confronted by our worst nightmares, the choices are few; Fight or
flight. We hope to find the strength to stand against our fears but
sometimes, despite ourselves, we run. What if the nightmare gives chase?
Where can we hide then?
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 [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