Re: How to Retrieve Query() Results

2007-10-22 Thread Cheeze

Ah... I seem to have found the answer.

$this->ProductsUsers->getAffectedRows() will return non-zero for any
changes made. Can use this to check for successful operation.

On Oct 23, 10:19 am, Cheeze <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have some questions on getting results of a query function call.
>
> E.g.
>
> $this->ProductsUsers->query("UPDATE `products_users` SET
> `modified`=NOW() WHERE `product_id`='{$pid}' AND `user_id`='{$uid}'");
>
> How do I know whether the operation completed with any errors? E.g.
> whether this statement created any errors or was it successful?
>
> I checked the return value of query(). But because it is not a SELECT
> call, nothing is returned i.e. the array is empty.
>
> I checked getNumRows() but it returned 0 even if the operation was
> completed successfully.
>
> The above statement is made in the ProductsController. I created a
> model for the join table because I store some attributes in the join
> table. I then gave ProductsController access to the ProductsUsers
> model using:
> $uses = array('Product', 'ProductsUsers')
>
> I'm using Cake 1.1
>
> Thanks in advance!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



How to Retrieve Query() Results

2007-10-22 Thread Cheeze

Hi,

I have some questions on getting results of a query function call.

E.g.

$this->ProductsUsers->query("UPDATE `products_users` SET
`modified`=NOW() WHERE `product_id`='{$pid}' AND `user_id`='{$uid}'");

How do I know whether the operation completed with any errors? E.g.
whether this statement created any errors or was it successful?

I checked the return value of query(). But because it is not a SELECT
call, nothing is returned i.e. the array is empty.

I checked getNumRows() but it returned 0 even if the operation was
completed successfully.

The above statement is made in the ProductsController. I created a
model for the join table because I store some attributes in the join
table. I then gave ProductsController access to the ProductsUsers
model using:
$uses = array('Product', 'ProductsUsers')

I'm using Cake 1.1

Thanks in advance!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---