<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NeatCN(NeatStudio工作室) &#187; bootstrap</title>
	<atom:link href="http://www.neatcn.com/tags/bootstrap/feed" rel="self" type="application/rss+xml" />
	<link>http://www.neatcn.com</link>
	<description>NeatStudio工作室</description>
	<lastBuildDate>Fri, 09 Dec 2011 13:07:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>为Zend的table加上prefix</title>
		<link>http://www.neatcn.com/show-36-1.shtml</link>
		<comments>http://www.neatcn.com/show-36-1.shtml#comments</comments>
		<pubDate>Wed, 24 Mar 2010 07:41:56 +0000</pubDate>
		<dc:creator>膘叔</dc:creator>
				<category><![CDATA[PHP开发]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend_db]]></category>

		<guid isPermaLink="false">http://www.neatcn.com/?p=36</guid>
		<description><![CDATA[我不知道别人是怎么做的。我做的很累啊。。。明明在继承Zend_Db_Table_Abstract的类中打印getAdapter方法时，有_config变量，但是，它是protected的，没有找到合适的方法调用。 于是没办法。到bootstrap.php文件里加了一个方法。 class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected $_bootConfig; public function __construct( $application ) { parent::__construct($application); $this->_bootConfig = new Zend_Config_Ini( APPLICATION_PATH . '/configs/application.ini' ); Zend_Registry::set('config', $this->_bootConfig); } } 这样。我在bootstrap中也能直接使用 $this->_bootConfig 的变量。因为我使用了smarty，而且用的不是继承的方法。所以直接在__construct方法中把config变量赋值出来也有一定的方便之处。 就象这样： public function _initView() { require_once ('Smarty/Smarty.class.php'); $tpl = &#8230; <a href="http://www.neatcn.com/show-36-1.shtml">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>我不知道别人是怎么做的。我做的很累啊。。。明明在继承Zend_Db_Table_Abstract的类中打印getAdapter方法时，有_config变量，但是，它是protected的，没有找到合适的方法调用。<br />
于是没办法。到bootstrap.php文件里加了一个方法。</p>
<pre class="brush:php">
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected $_bootConfig;

    public function  __construct( $application ) {
        parent::__construct($application);
        $this->_bootConfig = new Zend_Config_Ini( APPLICATION_PATH . '/configs/application.ini' );
        Zend_Registry::set('config', $this->_bootConfig);
    }
}
</pre>
<p>这样。我在bootstrap中也能直接使用 $this->_bootConfig 的变量。因为我使用了smarty，而且用的不是继承的方法。所以直接在__construct方法中把config变量赋值出来也有一定的方便之处。<br />
就象这样：</p>
<pre class="brush:php">
    public function _initView()
    {
        require_once ('Smarty/Smarty.class.php');
        $tpl = new Smarty();
        $tplSettings = $this->_bootConfig->staging->smarty->toArray();
        foreach( $tplSettings as $key=>$value){
            $tpl->$key = $value;
        }
        Zend_Registry::set( 'tpl', $tpl);
    }
</pre>
<p>这样 _initView 之后，一定要在 application.ini里设置<br />
resources.frontController.noViewRenderer = 1<br />
不过这样就没有办法用zend_view的layout 。。。<br />
于是我现在就在Zend_Db_Table_Abstract的继承类里用 init方法加了简单的处理</p>
<pre class="brush:php">
    public function init(){
        $config = Zend_Registry::get('config')->toArray();
        if(isset( $config['production']['resources']['db']['params']['prefix'] )){
            $prefix = strval( $config['production']['resources']['db']['params']['prefix'] );
            $this->_name =  $prefix . $this->_name ;
        }
    }
</pre>
<p>Over。解决。。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neatcn.com/show-36-1.shtml/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

