0
How do I link an article table to a table of favorite articles using cakephp 3.
bookmark table:
CREATE TABLE IF NOT EXISTS `favorites` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`article_id` int(11) NOT NULL,
`favorited` datetime NOT NULL
)
article table:
CREATE TABLE IF NOT EXISTS `articles` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`content` text NOT NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL
)
cakephp is not a database is a PHP framework, I believe that actually your doubt is about mysql, I’m sure?
– Guilherme Nascimento
In vdd is about the Cakephp Associations >> http://book.cakephp.org/3.0/en/orm/associations.html But when I try to make use of it it returns all the data in the article table when in vdd I should return only the articles associated with the bookmark table
– Guilherme Pichok
Are your tables in innoDB (or similar)? Do you use a foreign key? Post the actual structure of both tables (including foreign keys if you have it and if it is
n:m
the table in the middle of the two... IF IT’S N:M), I believe it is possible to do it. : ) I wait– Guilherme Nascimento
the foreing key would be made by the id of the Articles table and in the favorites table by the column 'article_id', it would be an association n:n. because every favorite article is a row in the favorites table
– Guilherme Pichok
You still don’t have the tables is this?
– Guilherme Nascimento
I have, but the problem is in the cake code where I can’t 'cross' these tables
– Guilherme Pichok
Then post what I asked in the comment, all tables that will relate, type of table and which Fields do the foreign key in the question please.
– Guilherme Nascimento
I updated the information in the 2 table
– Guilherme Pichok