English 中文(简体)
1. 延长自愿选择
原标题:extending zend db select

我正在建造一个CMS型站点,将有很多行政管理用户。 已为商业界制定了法律。 但是,我们现在想要将习俗ACL逻辑应用到以城市为基础的模式上,城市是行政管理使用者。

For eg: Admin user is from New York. He can view the content related to New York City.

I have lot of queries built with Zend_Db_Select in the models. Now I have change the queries everywhere. Is there a way, I can add the logic ->where( u.city_id = ? , $admin_user_city_id) for each and every query.

提前感谢。

Thanks Venu

最佳回答

我认为,你可能不需要延长<代码>。 Zend_Db_Table_Select。 你可以做些什么,只把<代码>Zend_Db_Table_Abstract与My_Db_Table_Abstract联系起来,你的模型也将延伸。 在这种抽象的类别中,你将默认的延伸到<条码>电子表示/编码>,该代码将回归<条码>Zend_Db_Table_Select,在返回之前,你只是在其中添加条款。

因此,每当你用<条码>my->选择(<>>/条码”的字句,就会在什么地方添加。

abstract class My_Db_Table_Abstract extends Zend_Db_Table_Abstract
{
    public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART)
    {
        $select = parent::select($withFromPart);
        # Retreive $admin_user_city_id
        $select -> where( u.city_id = ? , $admin_user_city_id);
        return $select;
    }
}

当然,这也意味着,根据你所依赖的模式,你在某个地方正确地加入到<条码>。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签