# |
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 |
# |
May 1st 2019, 08:58 |
voycey |
ok so not parent_id but just id1 id2 |
# |
May 1st 2019, 08:58 |
noel |
@voycey a parent id would be a self one to many. I need a self many to many. That’s the issue. I don’t understand how to create the required SQL structure for that along with the required model relationship settings. |
# |
May 1st 2019, 08:56 |
voycey |
you would just specify it in the association definition |
# |
May 1st 2019, 08:56 |
voycey |
I guess you would need to define a parent_id or however else you want to self join |
# |
May 1st 2019, 08:56 |
noel |
@voycey I saw that in the docs but it didn’t make sense to me. I mean what SQL changes / create would go along with that to enable the data to be saved? |
# |
May 1st 2019, 08:54 |
sam.parsons |
Hi, using CakePHP 3, I removed a parameter from my index function in a plugin controller, then got missing route error: Missing Route Cake\Routing\Exception\MissingRouteException Reverted all changes, deleted my cache folder, and now every page is giving this, any ideas? Thanks |
# |
May 1st 2019, 07:57 |
slackebot |
->contain( ['CompanyBooks'] ); ``` |
# |
May 1st 2019, 07:57 |
willem |
@admad any idea why the ORM istn using the Table class in my query from yesterday? If i add the type explicitly to the where it is working as it should, so i believe you are correct in saying it doesn’t load the schema. ``` $this->Transactions->find() ->where([ 'CompanyBooks.is_import_book_type' => true, ], ['CompanyBooks.is_import_book_type' => 'boolean'] ) |
# |
May 1st 2019, 07:55 |
ra7bi |
@admad Yes , i know it's not possible but i thought there is a way in somehow @mrfeedback this is what im doing now ,thnaks |
# |
May 1st 2019, 07:14 |
megan |
Sure no prob! |
# |
May 1st 2019, 07:14 |
kiwi_81 |
A thanks. I was abusing the Google cache, but that's better. :) |
# |
May 1st 2019, 07:13 |
roel |
@megan Oh, ok :slightly_smiling_face: Thanks :+1: |
# |
May 1st 2019, 07:13 |
megan |
in the meantime you could use https://book.cakephp.org/3.next/en/index.html in the meantime |
# |
May 1st 2019, 07:13 |
kiwi_81 |
Yep, it's only cakebook 3 |
# |
May 1st 2019, 07:13 |
megan |
Yupp - the team was working on the book last night, so prob related and hopefully up soon! |
# |
May 1st 2019, 07:12 |
roel |
It's only the 3.0 cook book, I guess? |
# |
May 1st 2019, 07:11 |
megan |
kiwi_81 - checking it out! |
# |
May 1st 2019, 06:58 |
kiwi_81 |
*down |
# |
May 1st 2019, 06:58 |
kiwi_81 |
It seems the whole Cake cookbook doc is done with a 404? |
# |
May 1st 2019, 06:54 |
mrfeedback |
@ra7bi you should define a global javascript var in your view and then check and access it in your javascript |
# |
May 1st 2019, 06:32 |
hippo |
are the docs working |
# |
May 1st 2019, 04:13 |
admad |
@ra7bi so you are asking whether you can use PHP code in a static JS file? |
# |
May 1st 2019, 03:48 |
ra7bi |
is it possible to use `<?= $this->request->webroot; ?>` in `webroot/js/file.js` |
# |
May 1st 2019, 00:45 |
voycey |
https://book.cakephp.org/3.0/en/orm/associations.html ``` class CategoriesTable extends Table { public function initialize(array $config) { $this->hasMany('SubCategories', [ 'className' => 'Categories' ]); $this->belongsTo('ParentCategories', [ 'className' => 'Categories' ]); } }``` |
# |
May 1st 2019, 00:41 |
voycey |
@noel I think you would just need to create an association back to the same table class with the field that you plan to self join on |