# |
Dec 3rd 2019, 15:22 |
birdy247 |
The Model.Initalize is hit fine |
# |
Dec 3rd 2019, 15:20 |
birdy247 |
EventManager::instance()->on('Model.initialize', function (Event $event) { //TODO - attach the tenant scope for all ArticlesManager tables if ($event->getSubject()->getRegistryAlias() == "ArticlesManager.Articles") { } |
# |
Dec 3rd 2019, 15:19 |
birdy247 |
We have attached an event listener in our bootstrap.php file |
# |
Dec 3rd 2019, 15:19 |
birdy247 |
Hi |
# |
Dec 3rd 2019, 15:12 |
ndm |
@ckjksl The result set that point 2 refers to is basically the result set from point 3 and 4. After results have been retrieved, being it from cache, or from the database, that result set will be assigned to a property of the query instance, and will be returned for all subsequent requests to fetch results for that query instance (until it's being marked dirty). https://github.com/cakephp/cakephp/blob/3.8.6/src/Datasource/QueryTrait.php#L298 |
# |
Dec 3rd 2019, 15:07 |
gianmarxgagliardi |
thanks |
# |
Dec 3rd 2019, 15:06 |
gianmarxgagliardi |
@neon1024 wroooooooooooooooooooo |
# |
Dec 3rd 2019, 15:06 |
gianmarxgagliardi |
@neon1024 I solved -> https://stackoverflow.com/questions/59141547/cakephp-displays-the-id-display-table-name-from-two-different-tables-with-relati/59142515#59142515 |
# |
Dec 3rd 2019, 15:02 |
ckjksl |
haha, that's true. Does that mean in step 2., the query is able to ask for a "results set" without executing the query (as in step 4.)? |
# |
Dec 3rd 2019, 14:57 |
phpnut |
jacquelove1969 |
# |
Dec 3rd 2019, 14:54 |
neon1024 |
Otherwise your next query might work, but the cache would return no results ;) |
# |
Dec 3rd 2019, 14:53 |
neon1024 |
No point caching empty results right? |
# |
Dec 3rd 2019, 14:45 |
ckjksl |
I'm not sure which "results set" no. 2 is referring to |
# |
Dec 3rd 2019, 14:45 |
ckjksl |
3. The cache key will be resolved and cache data will be read. If the cache data is not empty, those results will be returned. 4. If the cache misses, the query will be executed and a new ResultSet will be created. This ResultSet will be written to the cache and returned. |
# |
Dec 3rd 2019, 14:44 |
ckjksl |
Does that mean that it will process the query through the database first before deciding whether to return the cached results or the (new) query results? |
# |
Dec 3rd 2019, 14:43 |
ckjksl |
When the results for a cached query are fetched the following happens: 1. The Model.beforeFind event is triggered. 2. If the query has results set, those will be returned. |
# |
Dec 3rd 2019, 14:43 |
ckjksl |
Sorry, I have a question about caching query results: https://book.cakephp.org/3/en/orm/query-builder.html#caching-query-results |
# |
Dec 3rd 2019, 14:40 |
scuadra |
if I have further issues I'll ask again for help :slightly_smiling_face: |
# |
Dec 3rd 2019, 14:39 |
scuadra |
thank you @dereuromark |
# |
Dec 3rd 2019, 14:39 |
scuadra |
all right |
# |
Dec 3rd 2019, 14:38 |
dereuromark |
yes, it is exactly the same from the outside. |
# |
Dec 3rd 2019, 14:36 |
scuadra |
Hello. I want to migrate a shell from Cake 2.x to 3.x. But I see that since version 3.6.0 shells are deprecated and I should use Console Commands. My Cake version is 3.7. So is it possible to run Console Command as cronjob in the same (or similar) way like shells? |
# |
Dec 3rd 2019, 13:10 |
javier.villanueva |
Now I have this... in the patched information |
# |
Dec 3rd 2019, 12:56 |
gianmarxgagliardi |
@neon1024 always the usual mistake even with the changes you suggested |
# |
Dec 3rd 2019, 12:54 |
david |
thank you @javier.villanueva |
# |
Dec 3rd 2019, 12:52 |
javier.villanueva |
But is better that you wait an expert opinion lol |
# |
Dec 3rd 2019, 12:51 |
javier.villanueva |
related_farms |
# |
Dec 3rd 2019, 12:51 |
javier.villanueva |
I think that is better create a Conect Model |
# |
Dec 3rd 2019, 12:51 |
david |
:slightly_smiling_face: |
# |
Dec 3rd 2019, 12:51 |
javier.villanueva |
mmmm |
# |
Dec 3rd 2019, 12:50 |
javier.villanueva |
changing foreing keys |
# |
Dec 3rd 2019, 12:50 |
javier.villanueva |
I think |
# |
Dec 3rd 2019, 12:50 |
javier.villanueva |
yes you need to add two belongsToMany assocs |
# |
Dec 3rd 2019, 12:49 |
david |
yes, that would be the default BTM way. But if I edit the city2_id I need to be related in a bidirectional way |
# |
Dec 3rd 2019, 12:48 |
javier.villanueva |
use too 'className' => 'Cities' |
# |
Dec 3rd 2019, 12:47 |
javier.villanueva |
(not checked) |
# |
Dec 3rd 2019, 12:47 |
javier.villanueva |
$this->belongsToMany('NearCities', [ 'foreignKey' => 'city1_id', 'targetForeignKey' => 'city2_id', 'joinTable' => 'cities_cities' ]); |
# |
Dec 3rd 2019, 12:45 |
javier.villanueva |
yes you can |
# |
Dec 3rd 2019, 12:44 |
david |
I have a "cities" which are near (or not) some of them to others. "cities_near" is a join table with "city1_id" and "city2_id". When a city is near to one, that one is near to the other. Can I do that in a smart way with belongsToMany? |
# |
Dec 3rd 2019, 12:30 |
javier.villanueva |
not is correct.... i check |
# |
Dec 3rd 2019, 12:29 |
javier.villanueva |
https://pastebin.com/4sp9YnWM |