You are not logged in.
Pages: 1
Hi!
Kindly view following link:
http://www.sitepoint.com/forums/showthr … ost4627974
Can some one guide me what and where Iam doing wrong and how it can be rectified.
Thanks in advance
Offline
Hi Bluesapphire,
first I'd like to welcome you to our humble little forum!
In terms of your question, what's the actual error you're getting? It looks like the i18n module is just building on the existing one-to-many architecture that Doctrine supports innately. Have you tried getting a simple one-to-many example working?
Offline
Thanks. Your casts are awasome and really inspired me to learn ZF.
I have following code in adition to previously mentioned code on sitepoint link:
Main Exam class:
<code>
class Model_Base_Exam extends Doctrine_Record {
public function setTableDefinition() {
$this->setTableName('exam');
$this->option('type', 'INNODB');
$this->option('charset', 'utf8');
$this->option('collate', 'utf8_general_ci');
$this->hasColumn('eid', 'integer', 11, array(
'primary' => true,
'unsigned' => true,
'notnull' => true,
));
}
public function setUp(){
$this->hasMany('Model_ExamTranslation as Translation', array(
'local' => 'eid',
'foreign' => 'etid',
'onUpdate' => 'CASCADE',
'onDelete' => 'RESTRICT',
'owningSide' => false,
));
$this->actAs('I18n', array(
'fields' => array('title'),
'className' => 'Model_ExamTranslation',
));
}
}
?>
</code>
Exam Translation Class :
<code>
<?php
class Model_Base_ExamTranslation extends Doctrine_Record {
public function setTableDefinition(){
$this->setTableName('exam_translation');
$this->option('type', 'INNODB');
$this->option('charset', 'utf8');
$this->option('collate', 'utf8_general_ci');
$this->hasColumn('etid', 'integer', 11, array(
'primary' => true,
'unsigned' => true,
'notnull' => true,
));
$this->hasColumn('lang', 'string', 2, array(
'primary' => true,
'notnull' => true,
));
$this->hasColumn('title', 'string', 1000);
$this->hasColumn('created', 'Timestamp');
$this->hasColumn('updated', 'Timestamp');
}
public function setUp(){
$this->hasOne('Model_Exam', array(
'local' => 'etid',
'foreign' => 'eid',
'owningSide' => true,
));
$this->actAs('Timestampable', array(
'created' => array(
'name' => 'created',
),
'updated' => array(
'name' => 'updated'
),
));
}
}
?>
</code>
Iam inserting data as follows:
<code>
$exam->Translation['en']->title = 'My English Title';
$exam->Translation['fr']->title = 'Fu Ku Ji Mun';
</code>
By running following statement:
<code>
print_r(print_r($exam->toArray()));
</code>
I get following array:
<code>
Array
(
[eid] => 6
[Translation] => Array
(
[en] => Array
(
[etid] => 6
[lang] =>
[title] => My English Title
[created] =>
[updated] =>
)
[fr] => Array
(
[etid] => 6
[lang] =>
[title] => Fu Ku Ji Mun
[created] =>
[updated] =>
)
)
)
</code>
The problem seems that 'lang' is not getting value.
Can I have guidance that what is going wrong in my code and how it can be rectified.
Thanks in advance
Offline
Isn't the second lang property redundant?
Offline
Sorry I didn't get your point. Iam just trying to mimic database tables and other details from following link:
http://www.doctrine-project.org/project … viors:i18n
Thanks
Offline
Pages: 1