# |
Feb 6th 2018, 13:39 |
h.mavisakalian |
so when I list categories |
# |
Feb 6th 2018, 13:39 |
h.mavisakalian |
I have another categories table, where I have category name and also tags field |
# |
Feb 6th 2018, 13:38 |
h.mavisakalian |
Now |
# |
Feb 6th 2018, 13:38 |
h.mavisakalian |
Every row in the table I am fetching data from has a string like I discribed ( these are tags ) : one,two,three,four |
# |
Feb 6th 2018, 13:37 |
hmic |
so you want ['one', 'two', 'three', 'four']? |
# |
Feb 6th 2018, 13:36 |
h.mavisakalian |
How can I fetch any row that has one of the values from the string2 |
# |
Feb 6th 2018, 13:35 |
h.mavisakalian |
string1 (table I am fetching data from): one,two,three,four string2: three,four |
# |
Feb 6th 2018, 13:35 |
hmic |
you can use where('tags IN' => ['first', 'second', 'third']) |
# |
Feb 6th 2018, 13:34 |
h.mavisakalian |
i have 2 strings - values seperated with commas |
# |
Feb 6th 2018, 13:34 |
h.mavisakalian |
Let me clarify… came out wrong |
# |
Feb 6th 2018, 13:34 |
hmic |
you need a fulltext search (column) to do that |
# |
Feb 6th 2018, 13:34 |
hmic |
ah, sql. no. like does not work on arrays, IN does |
# |
Feb 6th 2018, 13:33 |
hmic |
in_array()? |
# |
Feb 6th 2018, 13:33 |
h.mavisakalian |
find()->where([‘tags LIKE’ => $anyOfThisArraysValues]) |
# |
Feb 6th 2018, 13:33 |
h.mavisakalian |
is there a way to check if values from one array exist in the string ? |
# |
Feb 6th 2018, 13:32 |
h.mavisakalian |
@neon1024 Thanks. one more question if you have the time. |
# |
Feb 6th 2018, 13:15 |
neon1024 |
It wasn’t loading the plugin table class, but making an automatic one :slightly_smiling_face: |
# |
Feb 6th 2018, 13:09 |
neon1024 |
I am not seeing any output from my entity mutators. I am working in a plugin. I have set in the plugin Table class, `setEntity()` to the plugin entity, and still the Paginator is returning `Cake\ORM\Entity` instead of my entity class. What have I missed? |
# |
Feb 6th 2018, 12:35 |
neon1024 |
Thanks @admad |
# |
Feb 6th 2018, 12:34 |
neon1024 |
But any docs contribution is a good one :thumbsup: |
# |
Feb 6th 2018, 12:34 |
neon1024 |
Well I was going to be a little more verbose and talk about the marshaller |
# |
Feb 6th 2018, 12:30 |
admad |
@neon1024 https://github.com/cakephp/docs/pull/5602 |
# |
Feb 6th 2018, 12:25 |
neon1024 |
I’m sure there will be some discussion on the PR :slightly_smiling_face: |
# |
Feb 6th 2018, 12:24 |
neon1024 |
Which is why the docs confused me by putting the direct method first |
# |
Feb 6th 2018, 12:24 |
neon1024 |
I would think in most cases you’d want to use the Table class |
# |
Feb 6th 2018, 12:24 |
neon1024 |
The only difference I can see is the one I mentioned above |
# |
Feb 6th 2018, 12:23 |
neon1024 |
They both return an entity |
# |
Feb 6th 2018, 12:22 |
hmic |
Entity != TableEntity |
# |
Feb 6th 2018, 12:22 |
neon1024 |
What do you mean? The calling class or the result? |
# |
Feb 6th 2018, 12:19 |
hmic |
neon1024: what class is new Entity vs. $table->newEntity()? |
# |
Feb 6th 2018, 12:17 |
neon1024 |
Think I’ll suggest an amend to the docs when I’m done :slightly_smiling_face: |
# |
Feb 6th 2018, 12:16 |
neon1024 |
That feels like something which should be told to users here, https://book.cakephp.org/3.0/en/orm/entities.html#creating-entities |
# |
Feb 6th 2018, 12:15 |
neon1024 |
What is the difference between `$entity = new Entity(['foo' => 'bar']);` and `$entity = $this->Examples->newEntity(['foo' => 'bar']);` as in, why is using the repository different? Is it just that the Table class will run the marshaller, whereas direct instantiation will only assign values? |
# |
Feb 6th 2018, 12:13 |
neon1024 |
`find()->where(['tags LIKE' => $tags])` |
# |
Feb 6th 2018, 12:02 |
h.mavisakalian |
find(‘all’, [ ‘conditions’ => [ ‘user_id’ => $user[‘id’], ‘tags’ => ‘LIKE $string’ ] ]) |
# |
Feb 6th 2018, 12:02 |
h.mavisakalian |
something like |
# |
Feb 6th 2018, 12:01 |
h.mavisakalian |
How can I add a exists condition when fetching data from table ? example.. I need to see if the string contains data from another string… |
# |
Feb 6th 2018, 10:22 |
neon1024 |
With a find() I mean, obviously not a first() as that’s taking a single item from the collection |
# |
Feb 6th 2018, 10:22 |
neon1024 |
As a query returns a ResultSet which implement ResultSet interface, it is a sensible default to assume the collection contains entities? |
# |
Feb 6th 2018, 09:42 |
neon1024 |
Ahh a fork |
# |
Feb 6th 2018, 09:42 |
neon1024 |
https://github.com/dereuromark/CakePHP-DatabaseLog |