# |
Mar 6th 2018, 15:22 |
popperz0r |
ok will try, thanks! |
# |
Mar 6th 2018, 15:22 |
flavius |
you could also turn on query logging and see the actual query and find out why it doesnt work, or see the query in debugkit |
# |
Mar 6th 2018, 15:22 |
jeremyharris |
(the first example is one with concat and column identifiers) |
# |
Mar 6th 2018, 15:22 |
jeremyharris |
see: https://book.cakephp.org/3.0/en/orm/query-builder.html#using-sql-functions |
# |
Mar 6th 2018, 15:21 |
jeremyharris |
try non-qualified field names, like first_name instead of User.first_name. Otherwise you need to tell cake they’re identifiers |
# |
Mar 6th 2018, 15:20 |
popperz0r |
```Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.`full_name`, LeadType.label AS `LeadType__label`, Email.email AS `Email__email`' at line 1 ``` |
# |
Mar 6th 2018, 15:20 |
jeremyharris |
@popperz0r what’s the error |
# |
Mar 6th 2018, 15:20 |
Es0teric |
however, i am not entirely sure if it has to do with the plugin setup... eventhough its setup the default way plugins are |
# |
Mar 6th 2018, 15:20 |
slackebot |
'order' => ['UnqualifiedLead.id' => 'desc'] ])``` |
# |
Mar 6th 2018, 15:20 |
popperz0r |
```$unqualified_leads_table = $this->UnqualifiedLead->find('all',[ 'fields' => ['id', 'name', 'user_id', 'User.first_name', 'User.last_name', 'User.full_name' => $this->UnqualifiedLead->query()->func()->concat(['User.first_name', ' ', 'User.last_name']), 'LeadType.label', 'Email.email', 'Phone.number', 'City.city_name'], 'contain' => ['User', 'Phone', 'Email', 'City', 'Company', 'LeadType'], |
# |
Mar 6th 2018, 15:20 |
popperz0r |
@jeremyharris im not able to fetch results now :) |
# |
Mar 6th 2018, 15:19 |
Es0teric |
jeremyharris, sure... give me a sec |
# |
Mar 6th 2018, 15:17 |
jeremyharris |
can you provide a minimal example of what’s happening? |
# |
Mar 6th 2018, 15:15 |
Es0teric |
how do i get past that while maintaining the multidimensional data? |
# |
Mar 6th 2018, 15:15 |
Es0teric |
i have this problem with returning array types in cakephp 2.x -- now I have a multidimensional array in a method and i want to use the return value in a variable... but for some reason it keeps breaking the app silently |
# |
Mar 6th 2018, 15:14 |
jeremyharris |
my example assumed you were on the table |
# |
Mar 6th 2018, 15:14 |
jeremyharris |
$this->UnqualifiedLead->query() |
# |
Mar 6th 2018, 15:14 |
popperz0r |
```Call to undefined method App\Controller\Api\UnqualifiedLeadController::query()``` |
# |
Mar 6th 2018, 15:13 |
jeremyharris |
what do you mean? |
# |
Mar 6th 2018, 15:13 |
jeremyharris |
you can use it in that list |
# |
Mar 6th 2018, 15:13 |
popperz0r |
any change to set it inside fields? |
# |
Mar 6th 2018, 15:13 |
popperz0r |
i can see i have to put it outside |
# |
Mar 6th 2018, 15:13 |
slackebot |
['UnqualifiedLead.id' => 'desc'] ])->where(AuthorizationComponent::getUserAuthorizedLeadAccessCondition($this->Auth->User())['conditions'], AuthorizationComponent::getUserAuthorizedLeadAccessCondition($this->Auth->User())['value_type']) ->andWhere($include_conditions);``` |
# |
Mar 6th 2018, 15:13 |
popperz0r |
``` $unqualified_leads_table = $this->UnqualifiedLead->find('all',[ 'fields' => ['id', 'name', 'user_id', 'User.first_name', 'User.last_name', 'User.full_name' => $this->query()->func()->concat(['first_name', ' ', 'last_name']), 'LeadType.label', 'Email.email', 'Phone.number', 'City.city_name'], 'contain' => ['User', 'Phone', 'Email', 'City', 'Company', 'LeadType'], 'order' => |
# |
Mar 6th 2018, 15:13 |
popperz0r |
can i adjust it to this? |
# |
Mar 6th 2018, 15:12 |
jeremyharris |
in 2.x, virtual fields were actual SQL snippets like this, while in 3.x they are simply calculated properties on the entity object |
# |
Mar 6th 2018, 15:11 |
jeremyharris |
``` $query = $this->find() ->select(['full_name' => $this->query()->func()->concat(['first_name', ' ', 'last_name']); ``` |
# |
Mar 6th 2018, 15:10 |
jeremyharris |
something like this: |
# |
Mar 6th 2018, 15:09 |
jeremyharris |
instead, you’ll have to build it as an alias field via the orm |
# |
Mar 6th 2018, 15:09 |
jeremyharris |
you cannot in the class 2.x sense do it the same way. a virtual field on the entity is within PHP and calculated by PHP, and has nothing to do with SQL |
# |
Mar 6th 2018, 15:08 |
popperz0r |
now i need to make a request of a string which should query full_name LIKE '%string%' |
# |
Mar 6th 2018, 15:08 |
popperz0r |
is concats first_name and last_name |
# |
Mar 6th 2018, 15:08 |
popperz0r |
i created a virtual property inside User Entity named full_name |
# |
Mar 6th 2018, 15:07 |
jeremyharris |
perhaps an example of what you’re looking for would help us? |
# |
Mar 6th 2018, 15:06 |
popperz0r |
anyone use this? |
# |
Mar 6th 2018, 15:06 |
popperz0r |
it is killing me |
# |
Mar 6th 2018, 15:06 |
popperz0r |
im still strugling with virtual properties conditions |
# |
Mar 6th 2018, 15:06 |
popperz0r |
hi everyone |
# |
Mar 6th 2018, 14:17 |
neon1024 |
Afternoon everyone |
# |
Mar 6th 2018, 12:54 |
savant |
night all |
# |
Mar 6th 2018, 12:46 |
makallio85 |
Thanks for your time! Clarified things for me. |