This is my model:
class Product extends GlobalModel {
protected $table = 'product';
}
I want to update the table name oops_product instead product at runtime.
I found getTable(); to get the table name from model and its working fine:
$tableName = with(new Product)->getTable();
But when i set the table name using setTable(); as per GitHub solution, its not updating the table name.
with(new Product)->setTable("oops_produdct");
Is there anything wrong?
Help will be appreciated.
edited:
$product = new Product();
$product->getTable(); // output: product
$product->setTable("oops_product");
$product->getTable(); // output: oops_product
now when i run this
$product->all();
it executes
"select * from product"
instead of
"select * from oops_product"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…