I start at Yii, so I ask this question.
I have three tables.
First table
First table language(id, language_name)
// id is the primary key.
Second table
Second table verse(id, topic_id, surah_id, verse_text)
// id is the primary key,
Third table
Third table verse_translations(id, verse_id, language_id, translations_text)
// id - primary key, language_id - links to foreign keys with a language table,
// verse_id - links to foreign keys with a verse table.
Now my question.
I want to get a list of languages for available translations with specific verse_id
.? To do this, I want to make a relationship in the verse model file that will return the languages that are available to me, so how do I get the result in the view.? and what will be the changes in the poetic model, presentation and controller if any changes occur.
I wrote a MySQL query, which is below.
SELECT language.language_name from language
Inner Join verse_translations ON verse_translations.language_id = language.id
Where verse_translations.verse_id = 1
Yii.
gii.
.
public function relations()
{
return array(
'sorah' => array(self::BELONGS_TO, 'Sorah', 'sorah_id'),
'topic' => array(self::BELONGS_TO, 'Topic', 'topic_id'),
'verseFeedbacks' => array(self::HAS_MANY, 'VerseFeedback', 'verse_id'),
'verseImages' => array(self::HAS_MANY, 'VerseImages', 'verse_id'),
'verseLinks' => array(self::HAS_MANY, 'VerseLinks', 'verse_id'),
'verseTafseers' => array(self::HAS_MANY, 'VerseTafseer', 'verse_id'),
'verseTranslations' => array(self::HAS_MANY, 'VerseTranslations', 'verse_id'),
'language_name' => array(self::HAS_MANY, 'Language', 'id'),
);
}