# |
Oct 11th 2019, 05:46 |
spriz |
and do something like `return $fieldOne . '-' . $fieldTwo` but that can get messy and slow pretty quickly for lager collections :S |
# |
Oct 11th 2019, 05:45 |
spriz |
I guess you would need to use a function in the `->sort()` |
# |
Oct 11th 2019, 05:45 |
kgb.acct.personal |
@spriz Yes. Also assuming that those fields have different types |
# |
Oct 11th 2019, 05:44 |
spriz |
first by field 1, and then by field 2? |
# |
Oct 11th 2019, 05:44 |
spriz |
@kgb.acct.personal how would that be sorted? |
# |
Oct 11th 2019, 05:39 |
kgb.acct.personal |
How do I sort Collection using two fields? |
# |
Oct 11th 2019, 03:04 |
arai.mio.i |
Thank you! |
# |
Oct 11th 2019, 02:53 |
challgren |
@arai.mio.i `$query->enableHydration(false)` https://book.cakephp.org/3.0/en/orm/query-builder.html#getting-arrays-instead-of-entities |
# |
Oct 11th 2019, 02:20 |
Fastidius |
you can just use php to pull data |
# |
Oct 11th 2019, 02:19 |
Fastidius |
is it for display or manipulation? ie can you paginate? |
# |
Oct 11th 2019, 02:18 |
arai.mio.i |
Hello. I need your help. Is it possible to get DB data without convert to ResultSet and Entity? When getting 50K records including datetime column, it seems it takes a long time because all data is converted into Frozentime. |
# |
Oct 11th 2019, 02:18 |
Fastidius |
my new thing is that when we go into a record to view there are add pages which open to a new page. the page has a drop down for client but the client we were in is not selected.. is there an easy way to pass the index item number to a drop down on the opened form? it uses the same client ID value |
# |
Oct 11th 2019, 02:16 |
Fastidius |
hi all, as some of you know i am slowly getting my head around cakephp by playing with UI changes to make life better for users. |
# |
Oct 10th 2019, 19:22 |
ricksaccous |
best way imo |
# |
Oct 10th 2019, 19:22 |
risingtide |
So would I put it in my Posts model then? |
# |
Oct 10th 2019, 19:13 |
ricksaccous |
would be the "cleaner" way |
# |
Oct 10th 2019, 19:13 |
ricksaccous |
and just call that in your controller and be done with it |
# |
Oct 10th 2019, 19:13 |
ricksaccous |
$this->Posts->getLatestPost(int $projectId); |
# |
Oct 10th 2019, 19:13 |
ricksaccous |
if you just had it as a model method though you could just say |
# |
Oct 10th 2019, 19:13 |
ricksaccous |
int he controller you'd feed it the option, then you'd have latest_post available in the veiw |
# |
Oct 10th 2019, 19:12 |
ricksaccous |
in the entity it would be findandsetlatestpost |
# |
Oct 10th 2019, 19:12 |
ricksaccous |
well i was using your entity example |
# |
Oct 10th 2019, 19:10 |
risingtide |
sounds like I have to rewrite a lot |
# |
Oct 10th 2019, 19:10 |
risingtide |
I'm still confused |
# |
Oct 10th 2019, 19:10 |
risingtide |
and in the controller I'd set it as a feild? |
# |
Oct 10th 2019, 19:09 |
risingtide |
So in my Model I'd make the findAndSetLatestPost function |
# |
Oct 10th 2019, 19:04 |
ricksaccous |
you could always just grab it as a separate query given the project id/etc |
# |
Oct 10th 2019, 19:04 |
ricksaccous |
sounds more like business layer logic though |
# |
Oct 10th 2019, 19:01 |
ricksaccous |
you'd have to do some set up |
# |
Oct 10th 2019, 19:01 |
ricksaccous |
if you need to pass something in i don't see how you can just have it "available" |
# |
Oct 10th 2019, 19:01 |
ricksaccous |
or whatever |
# |
Oct 10th 2019, 19:01 |
ricksaccous |
$entity->findAndSetLatestPost($projectEntity->id); |
# |
Oct 10th 2019, 19:00 |
ricksaccous |
in your controller |
# |
Oct 10th 2019, 19:00 |
ricksaccous |
public function findAndSetLatestPost(int $somethingId) { $this->property = value} |
# |
Oct 10th 2019, 19:00 |
risingtide |
how would I do it in the controller? |
# |
Oct 10th 2019, 18:59 |
ricksaccous |
if you really need it in the entity you can have an arbitrary function that sets a field given an argument |
# |
Oct 10th 2019, 18:59 |
ricksaccous |
it would make sense to do it in the controller |
# |
Oct 10th 2019, 18:58 |
ricksaccous |
or where do you want to pass the argument |
# |
Oct 10th 2019, 18:58 |
ricksaccous |
the view? |
# |
Oct 10th 2019, 18:58 |
ricksaccous |
where are you passing the argument in anyway |
# |
Oct 10th 2019, 18:58 |
ricksaccous |
contain the posts and order it, i suppose limiting it by 1 won't have an effect |