# |
Jul 17th 2019, 07:47 |
admad |
@h.mavisakalian step 1: Figure out the SQL query you need to get the result you want |
# |
Jul 17th 2019, 07:47 |
conehead |
I think `IN` is at least one. So Even with 2 or more values it should show up |
# |
Jul 17th 2019, 07:46 |
h.mavisakalian |
also bring the results that have 2 of the array values in the title |
# |
Jul 17th 2019, 07:46 |
h.mavisakalian |
but |
# |
Jul 17th 2019, 07:46 |
h.mavisakalian |
$query = $this->Users->find(‘all’,[ ‘conditions’ => [‘name LIKE’ => $searchArray], ‘order’ => [‘Users.id’ => ‘ASC’] ]); |
# |
Jul 17th 2019, 07:46 |
h.mavisakalian |
something like this |
# |
Jul 17th 2019, 07:45 |
h.mavisakalian |
that is why I mentioned the LIKE |
# |
Jul 17th 2019, 07:45 |
h.mavisakalian |
@conehead Thank you, but I need something else… you see the problem is I need the query to give me the results of the rows that for example have 2 values from the array as well |
# |
Jul 17th 2019, 07:42 |
admad |
yes |
# |
Jul 17th 2019, 07:41 |
koeller |
@admad So the proper way would be that the client sends another index request? |
# |
Jul 17th 2019, 07:41 |
conehead |
@h.mavisakalian probably you need something like this: ``` $query = $this->Users->find(‘all’,[ ‘conditions’ => ['yourField IN' => $searchArray], ‘order’ => [‘Users.id’ => ‘ASC’] ]); ``` |
# |
Jul 17th 2019, 07:40 |
admad |
@koeller for a REST API for a delete request you just respond with a success/failure status |
# |
Jul 17th 2019, 07:39 |
admad |
@maymeow if it's a standalone plugin first plug it into an app :slightly_smiling_face: |
# |
Jul 17th 2019, 07:39 |
koeller |
@admad: Okay, what would be the best way then? setting a view variable with the result of the finder im using in index Action? |
# |
Jul 17th 2019, 07:39 |
graziel |
@maymeow you are probably missing cache config after updating cake https://github.com/cakephp/app/blob/master/config/app.default.php#L111 |
# |
Jul 17th 2019, 07:38 |
admad |
@koeller since you mention using JWT auth I assume you are working on a stateless REST API. There's no redirection for such requests. |
# |
Jul 17th 2019, 07:37 |
maymeow |
Any idea how to solve this? |
# |
Jul 17th 2019, 07:36 |
admad |
how do you expect `‘conditions’ => $searchArray` to work without specifying which fields/columns to use? |
# |
Jul 17th 2019, 07:35 |
dereuromark |
see awesome list |
# |
Jul 17th 2019, 07:35 |
h.mavisakalian |
which plugin is that? |
# |
Jul 17th 2019, 07:35 |
slackebot |
$this->Crud->on('afterDelete') with $this->redirect(['index']) and $this->setAction('index'), but I would only recieve a NotFoundException. I'm a bit puzzled here. Thank you for reading! |
# |
Jul 17th 2019, 07:35 |
koeller |
Hi everyone, I have a question regarding the friendsofcake/CRUD plugin. I'm doing a simple delete and try to redirect to index, so that the response of the request would be a list of all items for logged user. I'm using JWT as Authentication method. Reading this:https://crud.readthedocs.io/en/latest/actions/delete.html#crud-beforeredirect I thought, it should automatically redirect to index, but it won't. So I tried to manually redirect in |
# |
Jul 17th 2019, 07:35 |
dereuromark |
use Search plugin for this |
# |
Jul 17th 2019, 07:34 |
h.mavisakalian |
What am I doing wrong? |
# |
Jul 17th 2019, 07:34 |
h.mavisakalian |
But it doesn’t work |
# |
Jul 17th 2019, 07:34 |
h.mavisakalian |
$query = $this->Users->find(‘all’,[ ‘conditions’ => $searchArray, ‘order’ => [‘Users.id’ => ‘ASC’] ]); |
# |
Jul 17th 2019, 07:33 |
h.mavisakalian |
Now I want to search the database this way |
# |
Jul 17th 2019, 07:33 |
h.mavisakalian |
I created an array from a search query with all values using exlode(’ ’, $searchValue); |
# |
Jul 17th 2019, 07:31 |
h.mavisakalian |
Good morning everyone. I have a question about search queries in CakePHP 3.X |
# |
Jul 17th 2019, 07:25 |
aivaras.godliauskas |
here you can set conditions |
# |
Jul 17th 2019, 07:25 |
aivaras.godliauskas |
``` class ArticlesTable extends Table { public function initialize(array $config) { $this->hasMany('Comments') ->setConditions(['approved' => true]); $this->hasMany('UnapprovedComments', [ 'className' => 'Comments' ]) ->setConditions(['approved' => false]) ->setProperty('unapproved_comments'); } } ``` |
# |
Jul 17th 2019, 07:25 |
aivaras.godliauskas |
https://book.cakephp.org/3.0/en/orm/associations.html#default-association-conditions |
# |
Jul 17th 2019, 07:24 |
neon1024 |
I need gmp, sodium and intl |
# |
Jul 17th 2019, 07:24 |
neon1024 |
Anyone know where I can find package names for PHP extension for Debian Fastly? |
# |
Jul 17th 2019, 07:23 |
aivaras.godliauskas |
Hi @neon1024 Fun fact im useing n3on as my nic |
# |
Jul 17th 2019, 07:23 |
felix.robaglia |
I'd be curious how ! I'm an intern and have a lot to learn @aivaras.godliauskas ^^ How can I say it directly in the table ? |
# |
Jul 17th 2019, 07:23 |
neon1024 |
Morning all :wave: |
# |
Jul 17th 2019, 07:23 |
aivaras.godliauskas |
or you can try and use some kind of soft delete for example https://github.com/UseMuffin/Trash |
# |
Jul 17th 2019, 07:23 |
neon1024 |
I quite like creating my own query and passing it to the Paginator :slightly_smiling_face: |
# |
Jul 17th 2019, 07:22 |
aivaras.godliauskas |
if you want to do it right way you can add this condition in table itself, where realiation is defined |
# |
Jul 17th 2019, 07:22 |
admad |
no. read up about custom finders on manul |