开始琢磨Kohana。先看了一下Kohana 101,出现了一些问题。
当做到 http://localhost/kohana/index.php/test/bye 时,出现了问题。并没有期望的视图出现,而是
Fatal error: Call to a member function _kohana_load_view() on a non-object in Z:wwwKohanasystemlibrariesView.php on line 266
但是文档并没有提到是何原因。还好有Codeigniter打底。原来是清风在class中写了一个空的__contruct(),而101并没有用它。 把它去掉,或是在里面调用一下父类的构造函数就ok了。
使用Query Builder查询id=3的产品信息。用php5的method chaining方式:
$query = $this->db->select()
->where(‘id’,3)
->form(‘products’)
->get();
嗯,这个Codeigniter也有。
清风还发现了101的两个笔误:
1)20页,Products表插入数据的sql语句里,第三条少个结尾逗号。
2)在26页里,
$this->template->content->special = new View('pages/home_special');应该是
$this->template->content->special = new View('pages/home_content');
貌似发送mail时需要PEAR,否则出错:(,怀念Codeigniter的email类了。