Log message #4122396

# At Username Text
# Mar 6th 2018, 16:08 popperz0r using ->having
# Mar 6th 2018, 16:08 popperz0r ok i got it
# Mar 6th 2018, 16:07 neon1024 I’d like to propose your idea, I think it’s a good one
# Mar 6th 2018, 16:06 neon1024 At least an RFC I guess right?
# Mar 6th 2018, 16:06 neon1024 @dereuromark Do you think it’s worth a ticket? The issue of entity access in templates?
# Mar 6th 2018, 16:06 neon1024 Well, without a syntax error :P
# Mar 6th 2018, 16:05 neon1024 For example
# Mar 6th 2018, 16:05 neon1024 `$this->set('catalog', $this->Catalogs->find()->first()`
# Mar 6th 2018, 16:05 neon1024 It’s an instance of a class which extends `\Cake\ORM\Entity`
# Mar 6th 2018, 16:04 neon1024 There are not two types.
# Mar 6th 2018, 16:04 flavius but not an ORM entity, so which one?
# Mar 6th 2018, 16:04 neon1024 @flavius It’s an entity
# Mar 6th 2018, 16:03 flavius @neon1024 what type of object is `$catalog` in your template?
# Mar 6th 2018, 16:03 neon1024 Ah!
# Mar 6th 2018, 16:03 popperz0r ```(CONCAT(User.first_name, :param0, User.last_name)) AS `full_name````
# Mar 6th 2018, 16:03 neon1024 You’d get first and last, and use an entity mutator method instead as detailed in the book
# Mar 6th 2018, 16:03 neon1024 It doesn’t exist
# Mar 6th 2018, 16:03 neon1024 You can’t use full_name in your query
# Mar 6th 2018, 16:02 popperz0r i really gonna make a foreach and filter with php
# Mar 6th 2018, 16:02 neon1024 Perhaps I could do all this checking when setting stuff to the template in my controller, and set individual variables
# Mar 6th 2018, 16:02 popperz0r still
# Mar 6th 2018, 16:02 slackebot (UnqualifiedLead.phone_id) LEFT JOIN email Email ON Email.id = (UnqualifiedLead.email_id) LEFT JOIN city City ON City.id = (UnqualifiedLead.city_id) LEFT JOIN company Company ON Company.id = (UnqualifiedLead.company_id) LEFT JOIN lead_type LeadType ON LeadType.id = (UnqualifiedLead.lead_type_id) WHERE (`full_name` like :c1 AND Email.email like :c2) ORDER BY UnqualifiedLead.id desc```
# Mar 6th 2018, 16:02 popperz0r ````UnqualifiedLead__user_id`, User.first_name AS `User__first_name`, User.last_name AS `User__last_name`, LeadType.label AS `LeadType__label`, Email.email AS `Email__email`, Phone.number AS `Phone__number`, City.city_name AS `City__city_name`, (CONCAT(User.first_name, :param0, User.last_name)) AS `full_name` FROM unqualified_lead UnqualifiedLead LEFT JOIN user User ON User.id = (UnqualifiedLead.user_id) LEFT JOIN phone Phone ON Phone.id =
# Mar 6th 2018, 16:02 popperz0r ```Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'full_name' in 'where clause'```
# Mar 6th 2018, 16:02 popperz0r so this is happening
# Mar 6th 2018, 16:01 dereuromark well, that is a third issue
# Mar 6th 2018, 16:01 neon1024 But sure, `s/get/has`
# Mar 6th 2018, 16:01 neon1024 Has doesn’t check emptyness
# Mar 6th 2018, 16:01 neon1024 Which if you’re a designer in a template, seems very confusing
# Mar 6th 2018, 16:01 dereuromark why not ->has() then?^^
# Mar 6th 2018, 16:01 neon1024 I end up with `if (!empty($catalog->get('content') andand !empty($catalog->get('content')->get('adverts')) { // Output advert };`
# Mar 6th 2018, 16:00 dereuromark with nesting it must always use latter one of course!
# Mar 6th 2018, 16:00 dereuromark well, there are two use cases: get() and I dont care about existence - and get() but make sure it exists
# Mar 6th 2018, 15:59 neon1024 `$catalog->get('content')->get('adverts')` for example, could throw two fatals
# Mar 6th 2018, 15:59 neon1024 The fatal really disrupts my templates as I have to put lots of state checking in. Especially so with nested associations
# Mar 6th 2018, 15:59 neon1024 As it keeps away the magic, but allows developers like myself to allow the return of null
# Mar 6th 2018, 15:58 neon1024 That my friend is a super idea!
# Mar 6th 2018, 15:58 dereuromark neon: maybe get() should have a 2nd default param and if not null (empty string) it would return that instead. alternative: getIfExists() as soft version
# Mar 6th 2018, 15:58 flavius nevermind, those are ORM
# Mar 6th 2018, 15:57 flavius i use the proprieties, `$article->id` and such, never used entity functions in my template, but okay
# Mar 6th 2018, 15:56 jeremyharris the only time it wouldn’t work is if you accessed the prop directly from the entity, like $this->_properties[‘name’]