Moi. Teen yhtä sovellusta apuna käyttäen doctrinea, kielenä php zendillä. Yritän tehdä many-to-many relaatiota ja olen yrittänyt toimia tämän ohjeen mukaan: Doctrine
Nyt kun yritän "rebuildata" tietokannan doctrine rebuild-db komennolla, homma katkeaa virheeseen:
lainaus:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order INT, PRIMARY KEY(id, employee_id, office_id)) DEFAULT CHARACTER SET utf8 E' at line 1.
Failing Query: "CREATE TABLE employee_to_office (id INT AUTO_INCREMENT, employee_id INT, office_id INT, order INT, PRIMARY KEY(id, employee_id, office_id)) DEFAULT CHARACTER SET utf8 ENGINE = INNODB".
Ja vähän koodia:
BaseEmployee.php
public function setUp()
{
parent::setUp();
$this->hasMany('Office as Offices', array(
'refClass' => 'EmployeeToOffice',
'local' => 'employee_id',
'foreign' => 'office_id'));
}BaseOffice.php
..setup()
$this->hasMany('Employee as Employees', array(
'refClass' => 'EmployeeToOffice',
'local' => 'office_id',
'foreign' => 'employee_id'));BaseEmployeeToOffice.php
abstract class BaseEmployeeToOffice extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('employee_to_office');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('employee_id', 'integer', 4, array(
'primary' => true,
'type' => 'integer',
'length' => '4',
));
$this->hasColumn('office_id', 'integer', 4, array(
'primary' => true,
'type' => 'integer',
'length' => '4',
));
$this->hasColumn('order', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '4',
));
}
public function setUp()
{
parent::setUp();
}
}Mikähän tuossa mättää?
Niin ja oon siis luonut scheman noista modelseista ja sitten schemastahan tuo rebuild sitten vissiin kattelee noi tiedot.
Nonni, empä huomannu että ko. ohjesivulla oli:
"Please note that group is a reserved keyword so that is why we renamed the table to groups using the setTableName method. The other option is to turn on identifier quoting using the Doctrine_Core::ATTR_QUOTE_IDENTIFIER attribute so that the reserved word is escaped with quotes."
Ongelman sain korjattua, kun lisäsin:
$manager->setAttribute(Doctrine_Core::
Aihe on jo aika vanha, joten et voi enää vastata siihen.