当我提交名称时,此脚本不会将数据发送到数据库。为什么呢?
这是我的控制器:
class Controller_About extends Controller_Template{
public function action_index()
{
if(!empty($_POST['name'])){
$name = Model::factory('index')->insert_names($_POST['name']);;
$result= $name;
$this->template->site_name = Kohana::$config->load('common')->get('site_name');
$this->template->site_description = Kohana::$config->load('common')->get('site_description');
$this->template->page_title = 'About';
$this->template->content = View::factory('about/about')->set('result', $result);
$this->template->styles[] = 'index/index';
}}
}
答案 0 :(得分:2)
此问题与Why do I get error : Undefined variable?重复,但无论如何我都会回答:您忘了 - >执行()。 Read the docs