# |
Mar 6th 2018, 15:31 |
jeremyharris |
err nm |
# |
Mar 6th 2018, 15:31 |
jeremyharris |
it could be skipping the loop and returning an uninitialized var |
# |
Mar 6th 2018, 15:31 |
jeremyharris |
do you define $society_list before the loop? |
# |
Mar 6th 2018, 15:30 |
Es0teric |
jeremyharris https://kopy.io/kx4uN#line-29 its a little crude but that line 29 pretty much makes the app silently error |
# |
Mar 6th 2018, 15:25 |
jeremyharris |
it shouldn’t fail silently then. maybe nothing’s failing at all? again, just shooting in the dark without seeing anything to go on |
# |
Mar 6th 2018, 15:24 |
flavius |
check the logs |
# |
Mar 6th 2018, 15:24 |
Es0teric |
jeremyharris, full debugging IS on... |
# |
Mar 6th 2018, 15:24 |
jeremyharris |
Es0teric well not sure I can help then, but turn on full debugging and error reporting and start digging through them logs :) |
# |
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 |