# |
Sep 12th 2019, 16:35 |
jh |
for reference Rails's arel works the same pretty much afair |
# |
Sep 12th 2019, 16:35 |
this.impetus |
thanks! I mean I don't know if I'm going to make use of that today, but that's a paradigm-shifting insight (to me). |
# |
Sep 12th 2019, 16:35 |
this.impetus |
oh! |
# |
Sep 12th 2019, 16:35 |
this.impetus |
oooooh |
# |
Sep 12th 2019, 16:35 |
jh |
until you do that you can continue to build the query object, adding more finders, adding more conditionals etc |
# |
Sep 12th 2019, 16:34 |
jh |
foreach, or toArray() |
# |
Sep 12th 2019, 16:34 |
jh |
@this.impetus so the query builder in cakephp builds some object that then is converted to vendor specific (mariadb, postgres, etc) sql code and executed once you want to access data out of it |
# |
Sep 12th 2019, 16:20 |
this.impetus |
@jh It may help you to know that I am a front-end guy, haha; I loosely understand what you've said, but not really the implications beyond the simple idea that there are fast and slow, or efficient and inefficient ways to retrieve data. :S |
# |
Sep 12th 2019, 16:17 |
jh |
not sure about the contains though... probably only for the primary query |
# |
Sep 12th 2019, 16:16 |
jh |
->sql() will get you the sql (with placeholders) |
# |
Sep 12th 2019, 16:16 |
jh |
afair the query builder is lazy aka if you do not fetch something from it it is just a query object |
# |
Sep 12th 2019, 16:16 |
jh |
toArray() will also run formatResults and not sure if only then or earlier all the accessors in the entities |
# |
Sep 12th 2019, 16:13 |
this.impetus |
On any other day I'd be super curious about that, haha, today is just get-to-the-finish-line. But thanks modi |
# |
Sep 12th 2019, 16:12 |
ricksaccous |
pretty much transforms it into an array of entities, which is great because there is a lot you can do with entity magic |
# |
Sep 12th 2019, 16:11 |
this.impetus |
oh thank god. :the_horns: |
# |
Sep 12th 2019, 16:11 |
ricksaccous |
it won't be exactly like cakephp2 but yep |
# |
Sep 12th 2019, 16:10 |
ricksaccous |
->toArray |
# |
Sep 12th 2019, 16:10 |
this.impetus |
Last question today guys, I swear; is there any means at all of getting a query object to just dump an array of data as cake once did? One of those days where I jsut want to get the work done and do the learning on my own time... |
# |
Sep 12th 2019, 15:48 |
jh |
like so https://gist.github.com/inoas/1226835ee066cf54c3bf1f30b1ec028d |
# |
Sep 12th 2019, 15:46 |
jh |
@admad yay it works... custom AppErrorMiddleware |
# |
Sep 12th 2019, 15:45 |
jh |
I would be explicit about it. |
# |
Sep 12th 2019, 15:45 |
jh |
a references b references a |
# |
Sep 12th 2019, 15:45 |
jh |
@ricksaccous if you setup a recursive function, yes, but do not forget that there can be loops so you need to stop the looping |
# |
Sep 12th 2019, 15:43 |
this.impetus |
:slightly_smiling_face: |
# |
Sep 12th 2019, 15:43 |
ricksaccous |
oh well, good luck |
# |
Sep 12th 2019, 15:43 |
ricksaccous |
lolll |
# |
Sep 12th 2019, 15:43 |
ricksaccous |
70 page CV, would anyone even read that |
# |
Sep 12th 2019, 15:43 |
this.impetus |
He has a 70 page CV. Guy is a luminary. Haha, but in any case, failing to have found a magic bullet, I'll just do it by hand. thanks, as usual |
# |
Sep 12th 2019, 15:42 |
ricksaccous |
but it also sounds like if it's just a single CV how bad could the query actually be anyway |
# |
Sep 12th 2019, 15:42 |
ricksaccous |
welp, good luck sounds like you could adjust the associations based on request data though |
# |
Sep 12th 2019, 15:41 |
this.impetus |
lol I need all the fields, haha. I'm building a digital CV for an academic who wants it utterly modular so a visitor could assemble a PDF based on which lines they want, it's a crazy amount of work to just print out what is essentially a document |
# |
Sep 12th 2019, 15:40 |
ricksaccous |
i know it's tedious but sometimes it's worth it |
# |
Sep 12th 2019, 15:40 |
ricksaccous |
you might want to specify fields in the contain array if you could |
# |
Sep 12th 2019, 15:40 |
ricksaccous |
really really really slow |
# |
Sep 12th 2019, 15:39 |
ricksaccous |
that query might be really really really slow |
# |
Sep 12th 2019, 15:39 |
this.impetus |
recursive retrieval is indeed what I'm after here. I can just write this out as an array, it's just tedious |
# |
Sep 12th 2019, 15:39 |
ricksaccous |
not just all associations on the main table |
# |
Sep 12th 2019, 15:39 |
ricksaccous |
it seems he wants child associations of child associations |
# |
Sep 12th 2019, 15:38 |
this.impetus |
@jh I'll give that a shot, thanks |
# |
Sep 12th 2019, 15:38 |
ricksaccous |
@jh would that work recursively though? |
# |
Sep 12th 2019, 15:38 |
jh |
try get_class_methods($this->Articles) should have some getAssociations() or so class |