# |
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 |
# |
May 1st 2019, 00:40 |
voycey |
Was hoping there was some magic to do that - oh well! |
# |
Apr 30th 2019, 23:27 |
noel |
Specifically I want to know how to create a schema for a self many to many relationship (i.e. same table with many-to-many to self) so that Bake picks up the schema correctly. I’ve already figured it out for the other types (although some documentation on that would have been helpful.) |
# |
Apr 30th 2019, 23:25 |
noel |
Evening. Where can I find examples of schemas for the various relationship types of the ORM? |
# |
Apr 30th 2019, 20:52 |
rmamba |
figured it out. CakePHP doesn't like if indexes have same name as columns |
# |
Apr 30th 2019, 19:20 |
willem |
No. Normal tables. |
# |
Apr 30th 2019, 19:17 |
admad |
@willem it means your table class isnt being used in association hence ORM doesnt have it's schema info. Are those plugin tables? |
# |
Apr 30th 2019, 18:49 |
willem |
how could this happen. i have a tinyint (1) field as aboolean in the table. if i directly use the table and set the where to ' => false, the resulting sql is correctly cast to a 0. if i use this table in a joined query using contian and put the same in the where clause, it is cast incorrectly as a ‘ ' (string) ``` |
# |
Apr 30th 2019, 18:37 |
jeremyharris |
daniel95 yep, people are usually in here to help out. post your question and if someone’s here that can help, they’ll answer! :slightly_smiling_face: |
# |
Apr 30th 2019, 18:25 |
daniel95 |
Hello, is it possible to get some support here or not? BR daniel |