Closed mourafnd closed 2 years ago
Hi @mourafnd ! 👋
How are the structure of your tables? Do you have an id
auto increment?
These are my tables, for example:
-- PLAYER
CREATE TABLE `player` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- TEAM
CREATE TABLE `team` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`stadium_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`capacity` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Let me know. Best Regards, Mauro.-
Hi! I was using the database.sql from slim4-soccer-api-demo https://github.com/maurobonfietti/slim4-soccer-api-demo. Now I tried with these new tables and I got the same error. I'll start again from the scratch and I'll let you know if I was successful.
I started again, deleted all the project but kept the database and now it works!!! I don't know what happened. Maybe I did something stupid and I don't remember LOL.
Update:
database.sql from https://github.com/maurobonfietti/slim4-soccer-api-demo:
CREATE TABLE `player` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
From your comment:
CREATE TABLE `player` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
AUTO_INCREMENT=1 is the only difference.
Excellent. I'm glad it worked for you now!
It's fine as it is in the repository.
At this moment, is required a field ID
with an auto-increment, like this:
`id` int(11) NOT NULL AUTO_INCREMENT,
Thank you @mourafnd !
Hi!
I tried the tutorial "Desarrollar una API RESTful con PHP y Slim 4" but a got a error when I use compose test after creating the player and teams endpoints.
Any Ideas?
Thank so much!