-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
I have some problems using your README example.
First, I guess it should be:
$movies = new \Maphper\Maphper(new \Maphper\Datasource\Database($pdo, 'movie', 'id'));
instead of:
$movies = new \Maphper\Maphper(new \Maphper\Datasource\Database($pdo, 'actor', 'id'));
Then, I have to add
$movies[] = $movie1;
$movies[] = $movie2;
before using
$actor->movies[] = $movie1;
$actor->movies[] = $movie2;
otherwise it does not add movie to actor.
I don't know if this is an error in README or an unexpected behaviour of Maphper.
Finally, if I add editmode and the table does not exists
$actors = new \Maphper\Maphper(new \Maphper\DataSource\Database($pdo, 'actor', 'id', ['editmode' => true]));
$movies = new \Maphper\Maphper(new \Maphper\DataSource\Database($pdo, 'movie', 'id', ['editmode' => true]));
$cast = new \Maphper\Maphper(new \Maphper\Datasource\Database($pdo, 'cast', ['movieId', 'actorId'], ['editmode' => true]));
It does not save the second movie and actor correctly (with the above correction adding manually the movies).
My final dumb is:
CREATE TABLE "actor" (id INTEGER NOT NULL, `name` VARCHAR(255), PRIMARY KEY(id));
INSERT INTO "actor" VALUES(123,'Samuel L. Jackson');
CREATE TABLE "movie" (id INTEGER, `title` VARCHAR(255), PRIMARY KEY(id));
INSERT INTO "movie" VALUES(1,'Pulp Fiction');
CREATE TABLE "cast" (movieId VARCHAR(255) NOT NULL, actorId INTEGER NOT NULL, PRIMARY KEY(movieId, actorId));
INSERT INTO "cast" VALUES('1',123);
INSERT INTO "cast" VALUES('1',124);
Snakes on a Plane is not present and John Travolta is missing too except on cast with the 124 that appears