# |
Jul 10th 2019, 15:22 |
neon1024 |
Or better yet, use a custom finder on the table |
# |
Jul 10th 2019, 15:22 |
neon1024 |
If you wanted to stipulate ‘new’ you’d use a callback in the contain to add a where condition |
# |
Jul 10th 2019, 15:22 |
neon1024 |
Using contain will get you all associations |
# |
Jul 10th 2019, 15:21 |
neon1024 |
It’s my understanding that that’s literally it’s job |
# |
Jul 10th 2019, 15:21 |
neon1024 |
Yeah, you’re using inner join |
# |
Jul 10th 2019, 15:20 |
waspinator |
when I have both the `innerJoinWith` the article has to have a new `comment` AND a new `tag` to be included in the results |
# |
Jul 10th 2019, 15:19 |
waspinator |
well if an article only has a new comment I still want it |
# |
Jul 10th 2019, 15:19 |
neon1024 |
$this->Articles->find()->contain([‘Comments’, ‘Tags’])` |
# |
Jul 10th 2019, 15:19 |
neon1024 |
Like, logically they’d be equal right? |
# |
Jul 10th 2019, 15:19 |
neon1024 |
Wouldn’t that be an and? |
# |
Jul 10th 2019, 15:09 |
waspinator |
can you have two `->innerJoinWith`s do an `or` instead of an `and`? for example find all `articles` with new `comments` or new `tags` |
# |
Jul 10th 2019, 15:03 |
neon1024 |
Was just making sure it would work, but it seems everything works ;) |
# |
Jul 10th 2019, 15:03 |
neon1024 |
https://3v4l.org/59sPo |
# |
Jul 10th 2019, 15:03 |
neon1024 |
I’ll `use ($myTableInstance)` in my closure I guess |
# |
Jul 10th 2019, 15:02 |
neon1024 |
Thanks for the tips @ndm |
# |
Jul 10th 2019, 15:02 |
neon1024 |
Figured a transaction would be the way |
# |
Jul 10th 2019, 15:02 |
neon1024 |
..and change a field |
# |
Jul 10th 2019, 15:02 |
neon1024 |
Oh right, I want to duplicate 5-6 records |
# |
Jul 10th 2019, 15:00 |
ndm |
@neon1024 The callback receives a connection instance, not a query instance, there will be no query. And yes, you can use the ORM inside of a transaction, just make sure to set the `atomic` option to `false` when saving/deleting in case required (ie if you don't want to use nested transactions). |
# |
Jul 10th 2019, 14:55 |
inoas |
good evening guys |
# |
Jul 10th 2019, 14:55 |
inoas |
I really hope the next one is somewhere I can get to with a train even if it takes 30h |
# |
Jul 10th 2019, 14:54 |
inoas |
I need to go to some cake fest |
# |
Jul 10th 2019, 14:54 |
lorenzo |
no problem! |
# |
Jul 10th 2019, 14:54 |
inoas |
lorenzo thanks again for helping out, that saved me tons of time, I am certain an exists solution had worked too but it would have been clunky at best |
# |
Jul 10th 2019, 14:53 |
neon1024 |
I presume the callback would take a query instance? |
# |
Jul 10th 2019, 14:53 |
neon1024 |
Can I use this to run ORM queries? |
# |
Jul 10th 2019, 14:53 |
neon1024 |
https://book.cakephp.org/3.0/en/orm/database-basics.html#using-transactions |
# |
Jul 10th 2019, 14:49 |
neon1024 |
Better to use the duplicatable behaviour in a loop, or do a find and change the results and save all in one go? |
# |
Jul 10th 2019, 14:01 |
lubos |
Yep, from reading collections method it seems the best :slightly_smiling_face: |
# |
Jul 10th 2019, 14:00 |
neon1024 |
I’d probably look to remove it and append it to the collection |
# |
Jul 10th 2019, 13:59 |
neon1024 |
https://book.cakephp.org/3.0/en/core-libraries/collections.html#Cake\Collection\Collection::append |
# |
Jul 10th 2019, 13:54 |
lubos |
What is the best way to move one item from the collection to the end? |
# |
Jul 10th 2019, 13:41 |
neon1024 |
:) |
# |
Jul 10th 2019, 13:41 |
neon1024 |
No, starting with a `/` as in root |
# |
Jul 10th 2019, 13:41 |
this.impetus |
yeah, I got it, tyvm, it was a silly mistake on my part |
# |
Jul 10th 2019, 13:41 |
this.impetus |
oh my goodness. I see now. I was writing the URL wrong; it can't be relative from JS's perspective (ie. ../img/file.jpg doesn't work) |
# |
Jul 10th 2019, 13:40 |
neon1024 |
So `background-image: /img/example.jpg` would work as would `background-image: http://example.com/img/background-image.jpg` I’d think |
# |
Jul 10th 2019, 13:40 |
neon1024 |
In most instances web servers should be setup to serve files and folders directly |
# |
Jul 10th 2019, 13:40 |
neon1024 |
That will depend on the web server configuration |
# |
Jul 10th 2019, 13:39 |
this.impetus |
but I think I'm explaining myself poorly, or else I've misunderstood... can I just provide explicit URIs for content in the webroot folder? isn't it captured by modrewrite or something (not a backend guy, forgive me if I sound ridiculous)? |
# |
Jul 10th 2019, 13:37 |
this.impetus |
`style=` I rather think |