asakurayoh
unread,Sep 8, 2010, 3:32:05 PM9/8/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Outlet ORM
Hi.
For a reason I don't understand, my many-to-many relation does'nt
save.
Here my code:
//-----------------------
<?php
include('Outlet.php');
Outlet::init(include 'config.php');
$outlet = Outlet::getInstance();
include('BookEntity.php');
include('AuthorEntity.php');
$outlet->createProxies();
$author = new Author();
$author->Name = 'Isaac Asimov';
$book = new Book();
$book->Title = 'Foundation';
$book->getAuthors()->add($author);
$outlet->save($book);
//---------------------------
<?php
class Book {
public $Authors;
public function __construct () {
$this->setAuthors(new Collection());
}
public function getAuthors() {
return $this->Authors;
}
public function setAuthors(Collection $Authors) {
$this->Authors = $Authors;
}
}
//--------------------
<?php
class Author {
}
//---------------------
<?php
return array(
'connection' => array(
'dsn' => 'mysql:host=localhost;dbname=dbname',
'username' => 'username',
'password' => '*******',
'dialect' => 'mysql'
),
'classes' => array(
'Book' => array(
'table' => 'books',
'props' => array(
'ID' => array('id', 'int', array('pk'=>true,
'autoIncrement'=>true)),
'Title' => array('title', 'text')
),
'plural'=>'Books',
'associations' => array(
array('many-to-many', 'Author', array('table'=>'authors_books',
'tableKeyLocal'=>'id_books', 'tableKeyForeign'=>'id_authors'))
)
),
'Author' => array(
'table' => 'auteurs',
'props' => array(
'ID' => array('id', 'int', array('pk'=>true,
'autoIncrement'=>true)),
'Name' => array('name', 'text')
),
'plural'=>'Authors',
)
)
);
//---------------
So, as someone can help me on this?
The book is saved but not the author or the relation...
I found that in OutletMapper.php, at line 295 ("$children = $obj->
$getter();") the children is always empty.
If I var_dump $obj before this line, the Collection "Authors" is not
empty, but after, it's an empty "OutletCollection" that take it's
place...
I use the website download RC1 zip file.
I really like the way Outlet works and wan't to use it in my projects,
by it need a lots more of documentation, for all possibilities!
Thanks for your help!