I'm twiting

访问统计

free counters

使用 Zend Loader 时要注意的

以下内容来自:Reference Guide
Zend_Loader vs. require_once()
Zend_Loader 最适合于加载的文件名是变量的情况(例如你要加载的文件的名称来自于用户的输入或者某个方法的参数)。如果你加载的文件名或类名是一个常量(即确定的文件,如/lib/test.php),则使用 Zend_Loader 并不比传统的PHP函数 require_once()有什么优势。

其实 zf 还是很牛X的

由于工作需要,最近开始基于 zf 做开发,12m的代码,有很多的亮点,比如quoteInfo()。这个我就觉得很好很强大。其他优势还在发掘中,相信自己很快就能运用自如

转一贴,内容不难,却具启发性:zend历程 之 初认控制器

原文地址
一个简单的控制器:
class helloController extends Zend_Controller_Action
{
function indexAction()
{
echo “hi, this is my helloworld”;
}
function testAction()
{
$var1 = $this->_getParam(”var”);
echo “hello”.$book_id;
}
function __call($action,$args){ $this->_redirect(’/hello’); }
}
运行结果是这样的:
http://localhost/hello/test/var/world 会显示 hellowrold
http://localhost/hello/netaction 时,会显示 hi, this is my helloworld
其实我想说明的也就上面分色的两点:
红:在Zend中,我有接收参数,不管是 post 还是 get 的,只要用 如:
$this->_getParam(”var”);
的形式即可,
final protected function _getParam($paramName, $default = null) 是控制器的私有方法,它还要可是带第二个参数,作为默认值,当没有得到你想要的参数时,返回这个默认值。
蓝:这个函数的目的为是,当访问的方法不存在时,自己转到一个地址(这里就是:http://localhost/hello 了)

Zend Framework quoteInfo 函数

$where = $this->db->quoteInto(”id = ?”, $label_id);
相当于 $where = “id = {$label_id}”;这个函数主要功能是防止 SQL 注入