Thursday, October 28, 2010

Re: Complex SQL queries

> how is the xml error related to your use of query.

Well, I think it is because the array that is coming back contains two
sub-arrays:

array(4) {
[0]=>
array(2) {
["seatavail"]=>
array(5) {
["ThtId"]=>
string(3) "500"
["ShoId"]=>
string(3) "100"
["PerTime"]=>
string(19) "2011-01-11 13:00:00"
["SroID"]=>
string(1) "a"
["firstUnused"]=>
string(1) "1"
}
[0]=>
array(1) {
["lastUnused"]=>
string(2) "15"
}
}

Which $xml->serialize($var); barfs on.

I really just want to delete the second array, but I can't change the
query as it is a necessary value for the HAVING clause.

I'm trying to use afterFind to remove it, but struggling..


> using query inside a controller is pretty anti-MVC - at the very least
> you should put the unmodified query into your model and call it from
> the controller as:
> $foo = $this->Model->functionICreated($params);
>
> remember: fat models, thin controllers.

A very good point and I've now switched to doing just that. I'm fairly
new to MVC and OO in general.

Thanks for your help!

-- joe.

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: