Re: Custom SQL queries, binding and organizing results

2008-07-10 Thread [EMAIL PROTECTED]

Did you get an answer? Or do you have a solution?

If so, could you post it?
I'm having the same problem.

Jos

On 19 mei, 13:26, David Christopher Zentgraf [EMAIL PROTECTED] wrote:
 Sorry for being a bit short there. :-)

 I think I get this kind of array when using finderQueries.
 Cake seems to organize the data to a certain extend, but not quite
 right.
 What I need would be:

 Array
 (
 [0] = Array
 (
 [Transaction] = Array
 (
 [id] .
 [Intermediator] = Array
 (
 [0] = Array
 (
 [id] 
 
 
 [Account] = Array
 )
 )
 )
 )
 )

 And so on.
 The models are all chained, not all belonging to one model.
 So that's flatter than I need.

 On 19 May 2008, at 20:15, the_woodsman wrote:



  Sorry, I don't understand - the output you posted

  Array
  (
  [0] = Array
  (
  [Transaction] = Array (...)
  [Intermediator] = Array (...)
  [Account] = Array (...)
  [User] = Array (...)
  )

  [1] = Array ...
  )

  Has been modified from a normal mysqlqueryresult... in what way is
  this a flat array?
  What output are you trying to achieve?

  On May 19, 11:39 am, David Christopher Zentgraf [EMAIL PROTECTED]
  wrote:
  I see, thanks!

  I played around with finderQueries a bit more and got them to work to
  some extend, but not perfectly.
  Depending on which model I'm querying from, Cake throws away part of
  the results I'd like to keep, as it doesn't seem to think the result
  is related enough to the querying model.

  Is there a recommended/best way to implement custom queries?
  I'd hate to do it in the controller, so I was thinking about defining
  a bunch of custom Model functions and using raw SQL which I'll have
  to
  sort through. How does that work with table prefixes, for example?
  Will Cake still prefix my tables or how would I take care of that
  myself?

  Chrs,
  Dav

  On 19 May 2008, at 17:13, Filip Camerman wrote:

  I don't think and wouldn't expect Cake to have any functionality
  to do
  that; when you're rolling your own queries you've got to live with
  the
  flat result. If you sort yourqueryright (e.g. by user) then it
  should be easy torearrangethe result in a hierarchical structure
  though.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL queries, binding and organizing results

2008-05-19 Thread Filip Camerman

I don't think and wouldn't expect Cake to have any functionality to do
that; when you're rolling your own queries you've got to live with the
flat result. If you sort your query right (e.g. by user) then it
should be easy to rearrange the result in a hierarchical structure
though.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL queries, binding and organizing results

2008-05-19 Thread David Christopher Zentgraf

I see, thanks!

I played around with finderQueries a bit more and got them to work to  
some extend, but not perfectly.
Depending on which model I'm querying from, Cake throws away part of  
the results I'd like to keep, as it doesn't seem to think the result  
is related enough to the querying model.

Is there a recommended/best way to implement custom queries?
I'd hate to do it in the controller, so I was thinking about defining  
a bunch of custom Model functions and using raw SQL which I'll have to  
sort through. How does that work with table prefixes, for example?  
Will Cake still prefix my tables or how would I take care of that  
myself?

Chrs,
Dav

On 19 May 2008, at 17:13, Filip Camerman wrote:


 I don't think and wouldn't expect Cake to have any functionality to do
 that; when you're rolling your own queries you've got to live with the
 flat result. If you sort your query right (e.g. by user) then it
 should be easy to rearrange the result in a hierarchical structure
 though.

 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL queries, binding and organizing results

2008-05-19 Thread the_woodsman

Sorry, I don't understand - the output you posted

Array
(
 [0] = Array
 (
 [Transaction] = Array (...)
 [Intermediator] = Array (...)
 [Account] = Array (...)
 [User] = Array (...)
 )

 [1] = Array ...
)

Has been modified from a normal mysql query result... in what way is
this a flat array?
What output are you trying to achieve?




On May 19, 11:39 am, David Christopher Zentgraf [EMAIL PROTECTED]
wrote:
 I see, thanks!

 I played around with finderQueries a bit more and got them to work to
 some extend, but not perfectly.
 Depending on which model I'm querying from, Cake throws away part of
 the results I'd like to keep, as it doesn't seem to think the result
 is related enough to the querying model.

 Is there a recommended/best way to implement custom queries?
 I'd hate to do it in the controller, so I was thinking about defining
 a bunch of custom Model functions and using raw SQL which I'll have to
 sort through. How does that work with table prefixes, for example?
 Will Cake still prefix my tables or how would I take care of that
 myself?

 Chrs,
 Dav

 On 19 May 2008, at 17:13, Filip Camerman wrote:



  I don't think and wouldn't expect Cake to have any functionality to do
  that; when you're rolling your own queries you've got to live with the
  flat result. If you sort your query right (e.g. by user) then it
  should be easy to rearrange the result in a hierarchical structure
  though.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL queries, binding and organizing results

2008-05-19 Thread David Christopher Zentgraf

Sorry for being a bit short there. :-)

I think I get this kind of array when using finderQueries.
Cake seems to organize the data to a certain extend, but not quite  
right.
What I need would be:

Array
(
[0] = Array
(
[Transaction] = Array
(
[id] .
[Intermediator] = Array
(
[0] = Array
(
[id] 


[Account] = Array
)
)
)
)
)

And so on.
The models are all chained, not all belonging to one model.
So that's flatter than I need.


On 19 May 2008, at 20:15, the_woodsman wrote:


 Sorry, I don't understand - the output you posted

 Array
 (
 [0] = Array
 (
 [Transaction] = Array (...)
 [Intermediator] = Array (...)
 [Account] = Array (...)
 [User] = Array (...)
 )

 [1] = Array ...
 )

 Has been modified from a normal mysql query result... in what way is
 this a flat array?
 What output are you trying to achieve?




 On May 19, 11:39 am, David Christopher Zentgraf [EMAIL PROTECTED]
 wrote:
 I see, thanks!

 I played around with finderQueries a bit more and got them to work to
 some extend, but not perfectly.
 Depending on which model I'm querying from, Cake throws away part of
 the results I'd like to keep, as it doesn't seem to think the result
 is related enough to the querying model.

 Is there a recommended/best way to implement custom queries?
 I'd hate to do it in the controller, so I was thinking about defining
 a bunch of custom Model functions and using raw SQL which I'll have  
 to
 sort through. How does that work with table prefixes, for example?
 Will Cake still prefix my tables or how would I take care of that
 myself?

 Chrs,
 Dav

 On 19 May 2008, at 17:13, Filip Camerman wrote:



 I don't think and wouldn't expect Cake to have any functionality  
 to do
 that; when you're rolling your own queries you've got to live with  
 the
 flat result. If you sort your query right (e.g. by user) then it
 should be easy to rearrange the result in a hierarchical structure
 though.
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Custom SQL queries, binding and organizing results

2008-05-16 Thread David Christopher Zentgraf

Hi,

I've read many posts on this topic, but I haven't figured out how to  
do it right yet.

I have four models linked together (Transaction hasMany Intermediators  
belongsTo Account belongsTo User), and I want to run a query on a  
removed cousin, like $this-Account-Intermediator-Transaction- 
 find('Account.id = xx').
Also, I need to optimize queries with LEFT JOINS, since Cake is  
creating hundreds of queries for a simple $this-paginate() for  
Transactions.
In a nutshell, I need to write my own SQL. A simple $this-query()  
works great, but I'm only getting a flat array back:

Array
(
 [0] = Array
 (
 [Transaction] = Array (...)
 [Intermediator] = Array (...)
 [Account] = Array (...)
 [User] = Array (...)
 )

 [1] = Array ...
)

What I want of course is a proper hierarchy of all my models in the  
result array.
How would I go about doing that, without doing it all manually in an  
afterFind()?

I've tried using the finderQuery property without any success, Cake  
just doesn't seem to use the finderQuery at all.
Any insight would be much appreciated.

(Cake 1.2 recent SVN checkout)

Chrs,
Dav

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---