Log message #4055448

# At Username Text
# Jul 21st 2017, 14:33 devito yea that would be a bad thing to forget hehe
# Jul 21st 2017, 14:33 devito mm
# Jul 21st 2017, 14:33 mirec do not forget two column index on (model, foreign_key) in your images table
# Jul 21st 2017, 14:32 devito yea
# Jul 21st 2017, 14:32 mirec yep I see... so Posts->hasMany('Images', ['conditions' => ['model' => 'Posts'], 'foreignKey' => 'foreign_key'])
# Jul 21st 2017, 14:31 devito a post can have many images
# Jul 21st 2017, 14:31 devito yea im tinkering with the assoiation configs now
# Jul 21st 2017, 14:31 mirec why do you have foreign_key in images table? why not Posts.image_id ?
# Jul 21st 2017, 14:30 devito I would just simply need to update the model column to point to the correc tmodel
# Jul 21st 2017, 14:30 devito smae for $this->Page->Image->path using the same table but without traditional foreign keys. Because if i make a new content type i dont want to have to add a new column to the db to accomidate it
# Jul 21st 2017, 14:29 mirec have you tried associations "conditions" config?
# Jul 21st 2017, 14:28 devito i want to be able to do $this->Post->iamge
# Jul 21st 2017, 14:26 mirec so you want something like $image->owner to be Post or Page ?
# Jul 21st 2017, 14:26 mikesmoniker @devito Something like https://github.com/robotusers/cakephp-table-inheritance might be a starting point.
# Jul 21st 2017, 14:26 devito setting to be saved that is...
# Jul 21st 2017, 14:25 devito my biggest concern with this approach is setting the entity data correctly.
# Jul 21st 2017, 14:24 mirec yep I got it, let me think
# Jul 21st 2017, 14:24 devito so the images table would be polymorphic as it belongs to both pages and posts but we would use foreign key and model to designate which one
# Jul 21st 2017, 14:23 devito imagine a images table that belongs to posts and pages however insted of a post_id / page_id we have a foreign_key and model column
# Jul 21st 2017, 14:22 mirec devito: what do you mean
# Jul 21st 2017, 14:22 devito has anyone experimented with polymorphic models in 3.x?
# Jul 21st 2017, 14:22 devito hello all
# Jul 21st 2017, 14:21 gutts yup filter does it. sweet thanks mirec
# Jul 21st 2017, 14:17 mirec https://book.cakephp.org/3.0/en/orm/query-builder.html#adding-calculated-fields
# Jul 21st 2017, 14:16 mirec on your resultset try $resultSet->filter(function($post){return count($post->comments) > 1})
# Jul 21st 2017, 14:15 mirec I do not think cachecounter will be helpful since you need Comments filtered dynamically by user_id
# Jul 21st 2017, 14:14 gutts or a cache counter
# Jul 21st 2017, 14:14 gutts ok, ill try to use mapreduce for that
# Jul 21st 2017, 14:13 mikesmoniker Is there a trick to getting cakephp-queuesadilla to use Predis? When I specify a className in the config, it gets overwritten to Redis because the DSN starts with redis://. cc @savant
# Jul 21st 2017, 14:12 mirec hasMany generates another query, so you cant use simple having mysql syntax. alternatively you can try CollectionTrait::filter()
# Jul 21st 2017, 14:09 mirec try mapReduce https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#map-reduce
# Jul 21st 2017, 14:01 gutts what about the having, how do i reference comments in relation to that?
# Jul 21st 2017, 14:00 gutts got that part
# Jul 21st 2017, 13:58 chris-andre https://book.cakephp.org/3.0/en/orm/query-builder.html#passing-conditions-to-contain
# Jul 21st 2017, 13:56 gutts so queryBuilder is a magic keyword?
# Jul 21st 2017, 13:56 chris-andre I think you could `->contain(['Comments' => ['queryBuilder' => function ($q) { return $q->where(['Comments.user_id !=' => 2]])`
# Jul 21st 2017, 13:55 gutts initially i tried to do this within comments but i need the structure reversed to parse
# Jul 21st 2017, 13:55 gutts i have two models - posts and comments. posts has a hasMany->Comments and Comments belongsTo posts
# Jul 21st 2017, 13:54 gutts in the overall scheme i need to apply a where clause on a hasMany and also need a having count > 1 of comments. so i want all active posts that have at least one comment and its not written by X user
# Jul 21st 2017, 13:54 chris-andre Right, and what column is not found? Comments.user_id?
# Jul 21st 2017, 13:53 gutts sorry, i meant posts