English 中文(简体)
动态创建 1. 密码示例
原标题:Dynamically Create Models by passing name parameter Kohana 3
  • 时间:2011-10-24 09:56:01
  •  标签:
  • kohana-3

I am using the Auto_Modeler class for data access and due to the nature of my app. I would like to use ` public static function check_AMexists($fieldname,$fieldvars,$model) {

$thismodel = new Model_Admin_$model();`

It used to work with ORM where I would simply pass the $model to ORM:factory($model). How do I go about passing the $model variable containing the modelname in my function?

最佳回答
$model_name =  Model_Admin_  . $model;
$model = new $model_name;
问题回答

暂无回答




相关问题
Favourite Kohana Tips & Features? [closed]

Inspired from the other community wikis, I m interested in hearing about the lesser known Kohana tips, tricks and features. Please, include only one tip per answer. Add Kohana versions if necessary. ...

Update query that needs to find the newest row

My logout function needs to update the latest row of a list of logins. This is what I have came up with, however it doesn t even pass syntax validation. $query = UPDATE user_logins SET ...

Is there a way to access datetime constants in Kohana 3?

Before I used a framework, I d often define things like so (so my code makes more sense to read) define( MINUTE , 60); define( HOUR , MINUTE * 60); // etc Is anything like this built into Kohana 3, ...

Send 404s to custom route in Kohana 3

I ve looked at how shadowhand (the main guy behind Kohana currently) set up his bootstrap.php file to handle exceptions on GitHub. I thought, "that s cool", so I incorporated something similar. ...

Get a random row from a database query in Kohana 3

I m using the ORM module in Kohana 3 and instead of displaying the first row of a database result set, what query should I use in my code when I want to get a random row from a certain table?

热门标签