我想在我的控制器中有一个可以在我的模型中访问的变量。例如,
<?php class MyController extends AppController{
function myFunction(){
// codes here
myvariable = "anything";
}
}
?>
在我的模型中,
<?php class myModel extends AppModel
function myModelFunction(){
// here i will use my variable to check on something.
if(myVariable != 0){ // myVariable here is from the controller
// do something here
}
}
?>
现在,我的代码是否可行,我的意思是是否可以从我的控制器访问一个变量,然后在我的模型上使用它进行检查或其他什么?谢谢。