Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
I can not dynamically change table name(dev-1.9)
I have following method in the model.
public static function set_table(int $user_id)
static::$_table_name = "tests_".substr(str_pad((string)$user_id,2,0,STR_PAD_LEFT),-2);
public static function add($user_id)
$prop = array('user_id'=>$user_id);
But, it dose not change the table name.
Do you have any suggetion for this?
Do not use self:, use static:. Late static binding is important if you change static properties.
in your model:
public static function table()
// some magic code
The model already has a static method for retrieving the table name.
The problem is that
self:: will call the original base model, not the current derived class. You need late static binding for that.
Sorry for late reply.
Thank you very much for your help.
I did not know that I have to use static:: all the time when I change static properties.
I still have to more about PHP.
Thank you, Harro
No worries, we've all been there.
Thank you, Harror
I always appreciate it .
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion