# |
Aug 25th 2016, 15:58 |
jaywalker |
How do you guys usually go about making an index/paginated page from data that's not represented 1-to-1 as a model/db table? |
# |
Aug 25th 2016, 15:23 |
dereuromark |
As $request->query becomes deprecated and one has to use $request->query() anyway |
# |
Aug 25th 2016, 15:22 |
dereuromark |
@btx In light of https://github.com/cakephp/cakephp/issues/9325 this becomes actually necessary to do now in 3.current |
# |
Aug 25th 2016, 15:18 |
dereuromark |
its a small feature for current master to allow that IMO |
# |
Aug 25th 2016, 15:18 |
dereuromark |
btx you wanna make a PR here? |
# |
Aug 25th 2016, 14:57 |
ypnos |
) |
# |
Aug 25th 2016, 14:57 |
ypnos |
btw I don't mind you write $a = find(); $a->morestuff($a->foo)), all I complained about was $a = find(); $a = $a->morestuff :9 |
# |
Aug 25th 2016, 14:55 |
ypnos |
I would always do the latter, basically because I like to abstract away all SQL code and be database agnostic, but I think it is a matter of taste |
# |
Aug 25th 2016, 14:54 |
saliak |
ypnos: yeah, in my current implementation, for sure (done actually). but if i wanted to implement my sum() function like in http://book.cakephp.org/3.0/en/orm/query-builder.html#using-sql-functions, instaad fo â??releasedâ??=>â??sum(fulfillmentItems.qtyâ??, to do â??releasedâ??=>$warehouse_skus->func()->sum(â??FulfillmentItems.qtyâ??), is a little easier. is there a benefit to doing the latter over the former? |
# |
Aug 25th 2016, 14:52 |
ypnos |
all I'm saying is cut the assignment from your statement, it is redundant, serves no purpose |
# |
Aug 25th 2016, 14:51 |
ypnos |
well what is the benefit of writing $variable = $variable? |
# |
Aug 25th 2016, 14:51 |
saliak |
ypnos: so I created a separate finder variable before. is there a downside to doing the function as I did? |
# |
Aug 25th 2016, 14:50 |
saliak |
ypnos: oh yeah, i previouly was doing the sum as $warehouse_skus->func->sum(â??FulfillmentItems.qtyâ??) |
# |
Aug 25th 2016, 14:50 |
ypnos |
yeah I saw you were confused with these two methods |
# |
Aug 25th 2016, 14:49 |
saliak |
ypnos: cool thanks.. man, i could have sworn i looked at leftJoin beforeâ?¦ must have gotten it mixed with leftJoinWith |
# |
Aug 25th 2016, 14:49 |
ypnos |
you can as well just write $foo->select()-> ... |
# |
Aug 25th 2016, 14:49 |
ypnos |
btw, $warehouse_skus = $warehouse_skus->select(-) is silly |
# |
Aug 25th 2016, 14:48 |
ypnos |
then this is the way to go |
# |
Aug 25th 2016, 14:48 |
ypnos |
ah but I see you have two fields per subquery |
# |
Aug 25th 2016, 14:48 |
ypnos |
easier to write down, code is then more comprehensible |
# |
Aug 25th 2016, 14:47 |
ypnos |
I would still do the select thing in your case probably |
# |
Aug 25th 2016, 14:47 |
ypnos |
yeah thats what I was talking about |
# |
Aug 25th 2016, 14:46 |
saliak |
ypnos: *BOOM*. nailed it! https://gist.github.com/anonymous/e187945cdb1cc91c59639d8e5039caf1 thanks so much for the pointers! |
# |
Aug 25th 2016, 14:42 |
birdy247 |
is there a more elegent way of building that? |
# |
Aug 25th 2016, 14:42 |
birdy247 |
all the body requests are built like this |
# |
Aug 25th 2016, 14:41 |
birdy247 |
I am looking at the sendgrid API documentations |
# |
Aug 25th 2016, 14:35 |
ypnos |
) |
# |
Aug 25th 2016, 14:35 |
saliak |
ypnos: yeah, youâ??re probably right. thanks for taking the time. lemme hack on this for a bit |
# |
Aug 25th 2016, 14:35 |
saliak |
ypnos: ahhh, i see. yeah, leftJoin is mucho more powerful |
# |
Aug 25th 2016, 14:35 |
birdy247 |
can you envisage any shortfalls with that? |
# |
Aug 25th 2016, 14:34 |
birdy247 |
I am thinking about a queue instead |
# |
Aug 25th 2016, 14:34 |
birdy247 |
Neon1024 you mentioned using a shell and cron to add my user to sendgrid |
# |
Aug 25th 2016, 14:34 |
saliak |
ok |
# |
Aug 25th 2016, 14:34 |
ypnos |
but have a look at the link I posted I think this is what you really want to do |
# |
Aug 25th 2016, 14:34 |
ypnos |
you can do whatever you want in leftJoin() |
# |
Aug 25th 2016, 14:33 |
ypnos |
listen there is a big difference between leftJoin() and leftJoinWith() |
# |
Aug 25th 2016, 14:33 |
saliak |
ypnos: so I canâ??t do a group/sum in the subquery, right? |
# |
Aug 25th 2016, 14:33 |
ypnos |
http://stackoverflow.com/questions/33884603/subqueries-in-cakephp-3 |
# |
Aug 25th 2016, 14:33 |
ypnos |
here in the answer is an example of what I mean: |
# |
Aug 25th 2016, 14:33 |
saliak |
so from http://api.cakephp.org/3.3/class-Cake.ORM.Query.html#_leftJoinWith, it says â??Please note that the query passed to the closure will only accept calling select, where, andWhere and orWhere on it. If you wish to add more complex clauses you can do it directly in the main query.â? |
# |
Aug 25th 2016, 14:32 |
ypnos |
what I had suggested earlier |