# |
Jun 15th 2018, 01:13 |
ricksaccous |
can collections help? |
# |
Jun 15th 2018, 01:13 |
cpierce |
is there a better way? |
# |
Jun 15th 2018, 01:12 |
cpierce |
best way i can figure is to pull them indivudally |
# |
Jun 15th 2018, 01:12 |
cpierce |
i need to loop through some data pulled form a database and then just keep looping and getting the rows under it ... |
# |
Jun 15th 2018, 01:12 |
cpierce |
what would be the proper place to put a recursive function in cakephp3.6? |
# |
Jun 14th 2018, 22:46 |
rightscoreanalysis |
if i debug $mainArticle in the view I see count 1 |
# |
Jun 14th 2018, 22:45 |
rightscoreanalysis |
in my view I am trying $mainArticle->id which doesn't work |
# |
Jun 14th 2018, 22:44 |
rightscoreanalysis |
$mainArticle = $articles->take(1); |
# |
Jun 14th 2018, 22:44 |
rightscoreanalysis |
If for example I use this in my controller: |
# |
Jun 14th 2018, 22:27 |
dereuromark |
it can be useful either way depending on what is needed. so no, not mandatory |
# |
Jun 14th 2018, 22:26 |
dereuromark |
the same way, its just an object that can be iterated |
# |
Jun 14th 2018, 22:19 |
rightscoreanalysis |
how can I access the data in my view if I don't use toArray |
# |
Jun 14th 2018, 22:15 |
dereuromark |
no its not mandatory |
# |
Jun 14th 2018, 22:12 |
rightscoreanalysis |
if I am doing a find->all() if is mandatory to call toArray right? This should be done before passing to the view? |
# |
Jun 14th 2018, 21:54 |
rightscoreanalysis |
@admad thanks |
# |
Jun 14th 2018, 21:12 |
squeeze |
hello all. Is there a way to connect different route is $this->Auth->User setted or not ? |
# |
Jun 14th 2018, 20:54 |
admad |
@rightscoreanalysis `$all = find()->all(); $first = $all->take(1); $remaining = $all->skip(1);` |
# |
Jun 14th 2018, 20:04 |
rightscoreanalysis |
is there any advantage in passing result object to the view template rather than an array |
# |
Jun 14th 2018, 20:03 |
rightscoreanalysis |
thanks |
# |
Jun 14th 2018, 20:01 |
edgaras.jan |
oh, use array_shift to get first, array_pop for last |
# |
Jun 14th 2018, 20:00 |
edgaras.jan |
`$rows = $query->toArray(); $first = array_pop($rows);` |
# |
Jun 14th 2018, 20:00 |
edgaras.jan |
yes |
# |
Jun 14th 2018, 19:59 |
rightscoreanalysis |
do i need to call toArray first? |
# |
Jun 14th 2018, 19:59 |
edgaras.jan |
`$first = array_pop($rows);`, $rows now contains 2-10 |
# |
Jun 14th 2018, 19:58 |
rightscoreanalysis |
any suggestion on how to do this, I could use toArray? But can I get the result as an object? |
# |
Jun 14th 2018, 19:57 |
rightscoreanalysis |
I am querying my table for 10 results, I want to split the results into different variables. So for example the first row should be passed into one varialb,e row 2-10 into another |
# |
Jun 14th 2018, 17:24 |
itamer |
thanks @neon1024, it's in the docs, works sometimes, I've put in a test and workaround. |
# |
Jun 14th 2018, 15:34 |
mikesmoniker |
`IdentifierExpression`? |
# |
Jun 14th 2018, 15:31 |
LubosR |
I mean for performance reason i don't want to quote all, just one identifier |
# |
Jun 14th 2018, 15:26 |
LubosR |
How do I escape reserved word (key) when savingData? I have quoteIdentifiers set to false and I want to escape it somehow when creating entity |
# |
Jun 14th 2018, 14:33 |
jeremyharris |
mm yeah reversing the key/value pairs works well, thanks again @admad @lorenzo |
# |
Jun 14th 2018, 14:31 |
jeremyharris |
thanks for the help! |
# |
Jun 14th 2018, 14:31 |
jeremyharris |
yep that’s it. okay I’ll go about it a different way |
# |
Jun 14th 2018, 14:31 |
jeremyharris |
ah |
# |
Jun 14th 2018, 14:30 |
lorenzo |
the same MAX() that is |
# |
Jun 14th 2018, 14:30 |
lorenzo |
there may be 2 values with the same key |
# |
Jun 14th 2018, 14:30 |
lorenzo |
ah, that’s the issue actually |
# |
Jun 14th 2018, 14:30 |
jeremyharris |
same result @admad, missing a record |
# |
Jun 14th 2018, 14:30 |
admad |
have you tried toList() instead of toArray() |
# |
Jun 14th 2018, 14:29 |
jeremyharris |
`SELECT (MAX(organization_id)) AS `organization_id`, (substring_index(Users.email, :param0, :param1)) AS `domain` FROM users Users GROUP BY domain ORDER BY domain` |
# |
Jun 14th 2018, 14:28 |
lorenzo |
what’s the generated query for that failing test case? |