Matt, query() is a model method (as you can see in the cookbook:
http://book.cakephp.org/view/456/query ). So there is no need to
"guess" what the syntax should be.

If you're doing it from the model, then you'd call it using $this-
>query();

If you're doing it from the model, but need to call it from an
associated model, then it would be: $this->AssociatedModel->query();

If you're doing it from a controller, then you would do it like so:
$this->MyModel->query();

The $this 'pseudo-variable' represents the current calling-object:
http://us2.php.net/manual/en/language.oop5.basic.php

And if you are making an update, then query() will not return any
data. If you are trying to check if the query succeeded or not, you
need to do use the 'identical' comparison (=== or !==):

if ($this->query($query) !== false) {
  // success
} else {
  // failed
}

On Jun 15, 9:17 am, Matt Y <[email protected]> wrote:
> So I have searched for this, but the cookbook does not help me with my
> problem.
>
> I have been trying to write functions in my models that use the
> query() function that updates some HABTM tables
>
> i have copied many pieces of code to try and make this happen but have
> had no luck. I have tried
>
> $results = $this->query();
> $results = $this->Model->query();
> $this->query();
> $this->Model->query();
>
> What am I doing wrong, is it just not possible to do this in model
> code, must I put all calls to the query function in the controller?
>
> Thank you for your help,
>
> Matt

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

Reply via email to