Hi,
I have an inheritance problem about my class…
This is my parent class:
<?php
class Gambling extends CActiveRecord {
/**
* Before save set the value of turn with the current turn
* @return Method of the parent class.
*/
public function beforeSave() {
if ($this->isNewRecord) {
$this->turn = Setting::getActualTurn();
}
return parent::beforeSave();
}
/**
* Pre-insert teams into the table.
*/
protected function _insertTeams($tableName)
{
echo "_insertTeams";
$cmdBuilder=Yii::app()->db->schema->commandBuilder;
$command=$cmdBuilder->createMultipleInsertCommand( $tableName, $this->_createInsertParamsOfTeams());
$command->execute();
}
/**
* Create the array of teams for the _inserTeams method.
* @return array data of team id and the current turn.
*/
private function _createInsertParamsOfTeams()
{
$data = array();
$teams = Team::model()->findAll();
$turn = Setting::getActualTurn();
foreach($teams as $team )
{
$data[] = array('team_id'=>$team['id'], 'turn'=>$turn);
}
return $data;
}
}
This is the child class:
class Result extends Gambling
{
//...
/**
* Start process for pre-insert teams into the table.
*/
public static function insertTeams()
{ echo "inserTeams";
self::model()->_insertTeams($this->tableName());
}
//...
}
My problem is that, the Result class, can’t call the _inserTeams() method… my app doesn’t view the “_inserTeams”…
- What is the problem? Why doesn’t call it?
If you see any problems, just say me I will happy for advises and tips