# |
May 1st 2019, 10:21 |
COOurb |
dunno |
# |
May 1st 2019, 10:20 |
neon1024 |
Probably easier to update your schema |
# |
May 1st 2019, 10:20 |
neon1024 |
..and using MySQL of course |
# |
May 1st 2019, 10:20 |
neon1024 |
That might be the root of your issue if you’re not escaping |
# |
May 1st 2019, 10:20 |
neon1024 |
Yes, it is. https://dev.mysql.com/doc/refman/5.7/en/keywords.html#keywords-5-7-detailed-D |
# |
May 1st 2019, 10:19 |
neon1024 |
Isn’t ‘date’ a reserved word? |
# |
May 1st 2019, 10:17 |
COOurb |
$this->addBehavior('Timestamp',['events'=>['Model.beforeSave'=>['date'=>'always']]]); |
# |
May 1st 2019, 10:16 |
neon1024 |
As you can see the behaviour foreach’s the config and updates those fields, https://github.com/cakephp/cakephp/blob/c15a2e9c1933fa5a874c33d2bcb6d63efacf8876/src/ORM/Behavior/TimestampBehavior.php#L101 |
# |
May 1st 2019, 10:15 |
neon1024 |
You can see here that the eventName is configured with specific fields, you overwrite these to use timestamp with your own fields |
# |
May 1st 2019, 10:15 |
neon1024 |
https://github.com/cakephp/cakephp/blob/c15a2e9c1933fa5a874c33d2bcb6d63efacf8876/src/ORM/Behavior/TimestampBehavior.php#L53-L56 |
# |
May 1st 2019, 10:13 |
COOurb |
?? sorry, didn't get it |
# |
May 1st 2019, 10:13 |
neon1024 |
Well, anyway, you’ll want to pass an array of config to the bejhaviour to add your field |
# |
May 1st 2019, 10:12 |
neon1024 |
https://downforeveryoneorjustme.com/book.cakephp.org |
# |
May 1st 2019, 10:12 |
COOurb |
I have it offline |
# |
May 1st 2019, 10:12 |
neon1024 |
@megan The cake book is 404 :( |
# |
May 1st 2019, 10:12 |
COOurb |
copy it from the book |
# |
May 1st 2019, 10:11 |
neon1024 |
@yannickfogang My first question would be why are you not using the ORM |
# |
May 1st 2019, 10:11 |
COOurb |
$this->addBehavior('Timestamp', ... |
# |
May 1st 2019, 10:11 |
COOurb |
yep. |
# |
May 1st 2019, 10:11 |
neon1024 |
COOurb, Did you configure the behaviour in your Table class to use the new field? |
# |
May 1st 2019, 10:04 |
COOurb |
type of date field it DATETIME |
# |
May 1st 2019, 10:04 |
COOurb |
entiry is changing - timestamp aren't |
# |
May 1st 2019, 10:04 |
COOurb |
hi, I can't assign timestamp behavior to custom field. |
# |
May 1st 2019, 09:46 |
noel |
@yannickfogang I had something similar yesterday and it was because my data was corrupt – some of the records NOT NULL but had null values. |
# |
May 1st 2019, 09:41 |
yannickfogang |
Hi everyone, I have a table with data, when i use the connectionManager to execute a prepared query with a limit of 15, my result array only contains 5 rows, yet the same query executing it with PDO or pgAdmin I get all the results. An idea about this problem? |
# |
May 1st 2019, 09:37 |
neon1024 |
Morning all :wave: |
# |
May 1st 2019, 09:23 |
martin |
hmm ok, that is dev book, but almost the same I think :P |
# |
May 1st 2019, 09:19 |
noel |
https://book.cakephp.org/3.next/en/index.html |
# |
May 1st 2019, 09:18 |
martin |
where did the book go? |
# |
May 1st 2019, 09:11 |
noel |
but how is that structure you’ve shown a many-to-many? Looks like it’s just pointing at id in the categories table. |
# |
May 1st 2019, 09:10 |
voycey |
Or you can use a join table as you were trying but honestly this sounds like its more complicated than it needs to be :slightly_smiling_face: |
# |
May 1st 2019, 09:09 |
voycey |
you just need to tell it what it needs to consider as a foreign key |
# |
May 1st 2019, 09:08 |
voycey |
cant test this but id assume it wouldnt have the categories_categories table: ```$this->hasMany('SubCategories', [ 'className' => 'Categories', 'foreignKey' => 'id1whatever', ]); $this->belongsTo('SubCategories', [ 'className' => 'Categories', 'foreignKey' => 'id2whatever', ]); ``` |
# |
May 1st 2019, 09:07 |
voycey |
Yeah its down |
# |
May 1st 2019, 09:07 |
noel |
A few other things also confuse me. So let’s say I have categories table with id and name. I’ll have a categories Entity class and Table class. To create a self referencing many to many, would I understand that I need a categories_categories table… but do I also need a corresponding CatogoryCatagory Entity and Table class? |
# |
May 1st 2019, 09:06 |
voycey |
Actually never mind - just loads of 404's from google for some reason |
# |
May 1st 2019, 09:06 |
voycey |
@megan or anyone - the Cake book is down |
# |
May 1st 2019, 09:02 |
noel |
@voycey I’ve put it into a stackoverflow question to make my mistakes more obvious :slightly_smiling_face: https://stackoverflow.com/questions/55930304/how-to-create-a-many-to-many-self-referencing-relationship-cakephp |
# |
May 1st 2019, 08:59 |
noel |
ok so I understand that in principle but in practise I can’t get it to work |
# |
May 1st 2019, 08:58 |
voycey |
then you can join whatever to whatever |
# |
May 1st 2019, 08:58 |
voycey |
for example |