creating database model without table name

Hello once again.

Can I do this is Yii?

creating a model that do not have a predefined table name but can give the table when creating an instances of it

eg.

<?php

class myModelName extends CActiveRecord{

protected $_tableName=null;

public function __construct($table){

&#036;this-&gt;_tableName = &#036;table

}

public function tableName()


{


	return &#036;this-&gt;_tableName;


}

}

?>

calling my Model in a controller class

<?php

$table = ‘chemistry’;

$model = new myModelName($table);

?>

so that i can use only this Model to have access to a hundred tables that have the same db structure ?

thanks once again.

Yes of corse is possible.

I did it for tables named like "note_2008", "note_2009", "note_2010".

You have just, like you correctly did, to edit ‘tableName()’

this is what I did but it didn’t work

<?php

class Subject extends CActiveRecord {

public function __construct($subject){

$this->subject = $subject;

}

public function tableName(){

return $this->subject;

}

?>

this gave me error in the view page

how should i do it?

Which error you get?

thanks it worked, just some error from my part