Log message #4189551

# At Username Text
# Jun 14th 2019, 08:34 dereuromark they "can" default to prod if you wanted to and only overwrite locally and for tests
# Jun 14th 2019, 08:33 dereuromark for me they would also be ENV then
# Jun 14th 2019, 08:32 kgb.acct.personal Application-wide constants, not sure where to put them
# Jun 14th 2019, 08:31 dereuromark what kind of extra configs? They are either persisted (no pwds, keys, etc) or defaulted to nothing and read from ENV where needed.
# Jun 14th 2019, 08:28 admad why not in app.php itself?
# Jun 14th 2019, 08:28 kgb.acct.personal So, where do I put extra configs? bootstrap.php?
# Jun 14th 2019, 08:27 admad bingo!
# Jun 14th 2019, 08:27 kgb.acct.personal Ah. I see, it's just for emulating environment variables
# Jun 14th 2019, 08:24 dereuromark why not using actual ENV to inject here?
# Jun 14th 2019, 08:23 kgb.acct.personal Because on `env.default` states: ``` # Having this file in production is considered a **SECURITY RISK** and also decreases # the boostrap performance of your application. ```
# Jun 14th 2019, 08:23 kgb.acct.personal Is it safe to use `.env` on prod?
# Jun 14th 2019, 08:23 neon1024 Morning everyone! :wave: Happy Friday :tada:
# Jun 14th 2019, 08:21 val Something like a bean in Java.
# Jun 14th 2019, 08:16 dereuromark see docs, they do if you have name or title field
# Jun 14th 2019, 08:12 noel Do tables have a default displayField or is this `id`?
# Jun 14th 2019, 08:00 noel This seems to work but not sure if it's DRY: ``` $exists = false; $connection = ConnectionManager::get('default'); $tables = $connection->execute('show tables;')->fetchAll('assoc'); foreach (array_values($tables[0]) as $key => $tableName) { if ($alias === $tableName) { $exists = true; } } return $exists; ```
# Jun 14th 2019, 07:54 noel What's the best way to check if a db table exists?
# Jun 14th 2019, 07:40 val Another way to optimize Entity would be to refactor $_properties array to a new class containing only those properties.
# Jun 14th 2019, 07:35 spriz Not sure how I feel about that, but it works! :)
# Jun 14th 2019, 07:35 spriz ->contain([ 'EanProductRelationTargets' => function (Query $q) { return $q->where(['EanProductRelations.type' => EanProductRelation::TYPE_ALTERNATIVE_PROCUREMENT]); }, ]);
# Jun 14th 2019, 07:35 spriz ```
# Jun 14th 2019, 07:35 spriz OK, I can actually just reference that join table in the where :thinking_face:
# Jun 14th 2019, 07:28 val I tested the memory by using `new MyEntity(...)` and generating the entities with some random values without any query to the database. So the memory overhead due to results buffering was not present.
# Jun 14th 2019, 07:28 spriz but how do I reference the join table and not either `articles` or `tags` table?
# Jun 14th 2019, 07:24 admad if that's not enough you could try using your own entity class implementation
# Jun 14th 2019, 07:24 challgren https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#using-innerjoinwith
# Jun 14th 2019, 07:24 admad depending on how you want to consume the results, i believe disabling results buffering might be the main thing that would help reduce memory consumption
# Jun 14th 2019, 07:24 spriz Data saved like this https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-additional-data-to-the-join-table :slightly_smiling_face:
# Jun 14th 2019, 07:23 val Okay. I believe there is a way to optimize Entity class a bit - $_properties is an array. It would use less memory if each property would be an actual class property instead of an array item in $_properties.
# Jun 14th 2019, 07:23 spriz now I only want all `tags` for an `article` that has priority `3`
# Jun 14th 2019, 07:23 spriz @challgren cheers mate, but I need to do it on the join table :S Consider `articles`, and `tags` and then `articles_tags` that has a column like `priority`
# Jun 14th 2019, 07:22 admad you can set your own entity class for the table to be used for hydration, but i think you will still have to use a class which implements EntityIterface
# Jun 14th 2019, 07:21 challgren @spriz https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#filtering-by-associated-data-via-matching-and-joins
# Jun 14th 2019, 07:19 admad so turn off hydration, disabled buffering and then use formatResults() to create objects of type you want
# Jun 14th 2019, 07:18 admad yes
# Jun 14th 2019, 07:18 val Perhaps $query->formatResults(...)?
# Jun 14th 2019, 07:15 val Using arrays is also not optimal. We try to optimize that. Is there an easy way to convert the cake's result set to our custom objects without too much custom coding?
# Jun 14th 2019, 07:13 admad if the memory consumed if still not within what you can spare than skip the ORM and directly use db level operations
# Jun 14th 2019, 07:12 admad 1st thing you can try in turning off hydration
# Jun 14th 2019, 07:12 admad so my statement "Objects take more memory than arrays" might not be factual but entities (within a resultset object) in cake 3 will take significantly more memory than corresponding arrays of cake 2
# Jun 14th 2019, 07:11 val That is correct.