标题: 初学者的ZFRC2测试DEMO
  本主题由 haohappy 于 2007-12-21 12:56 设置高亮 
chenjiafeng
新手上路
Rank: 1



UID 123
精华 0
积分 0
帖子 4
翻译 0
原创 0
阅读权限 10
注册 2007-6-26
状态 离线
发表于 2007-6-27 13:11  资料  短消息  加为好友  添加 chenjiafeng 为MSN好友 通过MSN和 chenjiafeng 交谈
Fatal error: Uncaught exception 'Zend_Config_Exception' with message 'Section 'zf' cannot be found in ./config/config.xml' in E:\AppServ\www\zf\library\Zend\Config\Xml.php:80 Stack trace: #0 E:\AppServ\www\zf\index.php(39): Zend_Config_Xml->__construct('./config/config...', 'zf') #1 {main} thrown in E:\AppServ\www\zf\library\Zend\Config\Xml.php on line 80
怎么我安装上出现这样的错误,是不是少文件啊?

顶部
mmocom
注册会员
Rank: 2



UID 58
精华 6
积分 70
帖子 21
翻译 0
原创 1
阅读权限 20
注册 2007-6-6
状态 离线
发表于 2007-6-27 15:12  资料  短消息  加为好友  添加 mmocom 为MSN好友 通过MSN和 mmocom 交谈


QUOTE:
原帖由 chenjiafeng 于 2007-6-27 13:11 发表
Fatal error: Uncaught exception 'Zend_Config_Exception' with message 'Section 'zf' cannot be found in ./config/config.xml' in E:\AppServ\www\zf\library\Zend\Config\Xml.php:80 Stack trace: #0 E:\AppSer ...

你修改的$dbconfig = new Zend_Config_Xml('./config/config.xml','mmocom');为$dbconfig = new Zend_Config_Xml('./config/config.xml','zf');

这个里面的mmocom是XML文件里的section~不是目录名
记得要开启PHP里的PHP_PDO

顶部
chenjiafeng
新手上路
Rank: 1



UID 123
精华 0
积分 0
帖子 4
翻译 0
原创 0
阅读权限 10
注册 2007-6-26
状态 离线
发表于 2007-6-27 17:04  资料  短消息  加为好友  添加 chenjiafeng 为MSN好友 通过MSN和 chenjiafeng 交谈
好的,谢谢

顶部
linren119
新手上路
Rank: 1



UID 94
精华 0
积分 0
帖子 5
翻译 0
原创 0
阅读权限 10
注册 2007-6-21
状态 离线
发表于 2007-7-3 10:38  资料  短消息  加为好友 
提供一份数据库

顶部
linren119
新手上路
Rank: 1



UID 94
精华 0
积分 0
帖子 5
翻译 0
原创 0
阅读权限 10
注册 2007-6-21
状态 离线
发表于 2007-7-3 10:52  资料  短消息  加为好友 
FormController.php的

$this->user = new Name();

这行的Name类是在那个文件里的?

顶部
linren119
新手上路
Rank: 1



UID 94
精华 0
积分 0
帖子 5
翻译 0
原创 0
阅读权限 10
注册 2007-6-21
状态 离线
发表于 2007-7-3 11:14  资料  短消息  加为好友 
找到了。。。。

顶部
123waily
新手上路
Rank: 1



UID 167
精华 0
积分 0
帖子 2
翻译 0
原创 0
阅读权限 10
注册 2007-7-9
状态 离线
发表于 2007-7-17 10:11  资料  短消息  加为好友 
mmocom ,提供一份数据库,
Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[42000] [1049] Unknown database 'mmocom'' in E:\AppServ\www\mmocom\library\Zend\Db\Adapter\Pdo\Abstract.php:131 Stack trace: #0 E:\AppServ\www\mmocom\library\Zend\Db\Adapter\Abstract.php(246): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 E:\AppServ\www\mmocom\library\Zend\Db\Adapter\Pdo\Abstract.php(206): Zend_Db_Adapter_Abstract->query('set names gbk;', Array) #2 E:\AppServ\www\mmocom\index.php(42): Zend_Db_Adapter_Pdo_Abstract->query('set names gbk;') #3 {main} thrown in E:\AppServ\www\mmocom\library\Zend\Db\Adapter\Pdo\Abstract.php on line 131

顶部
mmocom
注册会员
Rank: 2



UID 58
精华 6
积分 70
帖子 21
翻译 0
原创 1
阅读权限 20
注册 2007-6-6
状态 离线
发表于 2007-7-19 14:40  资料  短消息  加为好友  添加 mmocom 为MSN好友 通过MSN和 mmocom 交谈
Page(翻页类)用于Zend Framwork



<?php
// Page(翻页类)用于Zend Framwork
class Custom_Page_ZF
{
        var $path;                                          //路径
        var $totalnum;                //记录总数
        var $perpagenum;              //每一页显示的记录数
        var $totalpage;               //总页数
        var $curpage;                 //当前页码
        var $offsetnum;               //记录偏移量
        var $linkpage;                //url连接
        var $offsetpage = 5;          //页码偏移量,这里可随意更改
        var $disnum;                                  //显示可选择的页面数
        var $pagetype;                                  //显示样式
                  
        public function __construct($param)
        {
                $this->path = $param['path'];
                $this->totalnum = $param['totalnum'];
                $this->perpagenum = $param['perpagenum'];
                $this->curpage = isset( $param['curpage'] ) ? intval( $param['curpage'] ) : '1';
                $this->totalpage = ceil( $this->totalnum / $this->perpagenum );
                $this->offsetnum = $this->perpagenum * ( $this->curpage - 1 );               
                $this->disnum = $param['disnum'];//当调用getNumPage()时需要此参数       
        }

       
        function getCharPage()
        {
                if ( $this->totalnum > $this->perpagenum )//当总记录数大于每页记录数时
                {
                        if ( $this->curpage == 1 && $this->totalpage > 1 )//当前页为第1页并且总页数大于1
                        {
                       
                                $this->linkpage = "<a>首页</a>|<a>上一页</a>|<a href=".$this->path."/page/".( $this->curpage + 1 )." >下一页</a>|<a href=".$this->path."/page/".$this->totalpage." >尾页</a>";
                       
                        } elseif ( $this->curpage > 1 && $this->curpage < $this->totalpage ){//当前页大于1并且当前页小于总页数
                       
                                $this->linkpage = "<a href=".$this->path."/page/1 >首页<a>|"
                                                                . "<a href=".$this->path."/page/".($this->curpage-1)." >上一页</a>|"
                                                                . "<a href=".$this->path."/page/".($this->curpage+1)." >下一页</a>|"
                                                                . "<a href=".$this->path."/page/".$this->totalpage." >尾 页</a>";
                       
                        } elseif ( $this->curpage == $this->totalpage && $this->totalpage > 1 ){
                       
                                $this->linkpage = "<a href=".$this->path."/page/1 >首 页<a>|"
                                                                . "<a href=".$this->path."/page/".($this->curpage-1)." >上一页</a>|<a>下一页</a>|<a>尾页</a>";
                        }
                }
                return "<div id=\"pager\">".$this->linkpage."</div>";
        }
       
        function getNumPage()
        {
                //总记录数大于每页记录数
                if( $this->totalnum > $this->perpagenum )
                {
                        //要求显示的数字组页数大于总页数
                        if ( $this->disnum >= $this->totalpage )
                        {
                                $from = 1;
                                $to = $this->totalpage;
                        } else {
                                $from = $this->curpage - $this->offsetpage;
                                $to = $from + $this->disnum - 1;
                                if( $from < 1 ){
                                        $to = $this->curpage + 1 - $from;
                                        $from = 1;
                                        if ( $to - $from < $this->disnum ){
                                                $to = $this->disnum;
                                        }
                                } elseif ( $to > $this->totalpage ){
                                        $from = $this->totalpage - $disnum + 1;
                                        $to = $this->totalpage;
                                }
                               
                        }
                        $url = '';
                        for ( $i = $from; $i <= $to; $i++)
                        {
                                if( $this->curpage == $i )
                                {
                                        $url .= "<a>".$i."</a>";
                                }else{
                                        $url .= "<a href=".$this->path."/page/".$i." >".$i."</a>";
                                }
                        }
                       

                        $urlstart = "<a href=".$this->path."/page/1 >首页</a>"
                        . "<a href=".$this->path."/page/".( $this->curpage - 1 )." >上一页</a>";
                        $urlend = "<a href=".$this->path."/page/".( $this->curpage + 1 )." >下一页</a>";

                        //当前页为第1页并且总页数大于1
                        if( $this->curpage == 1 && $this->totalpage > 1 )
                        {
                                $this->linkpage = $url.$urlend;
                        }
                        elseif ( $this->curpage > 1 && $this->curpage < $this->totalpage )//当前页大于1并且当前页小于总页数
                        {
                                $this->linkpage = $urlstart.$url.$urlend;
                        }
                        elseif ( $this->curpage == $this->totalpage && $this->totalpage > 1 )
                        {
                                $this->linkpage = $urlstart.$url;
                        }

                       
                }else{
                        $this->linkpage = "1";
                }
                return "<div id=\"pager\">".$this->linkpage."</div>";
        }
       
        //获取总页数
        function getTotalPage()
        {
                return $this->totalpage;
        }
       
}
?>


顶部
mmocom
注册会员
Rank: 2



UID 58
精华 6
积分 70
帖子 21
翻译 0
原创 1
阅读权限 20
注册 2007-6-6
状态 离线
发表于 2007-7-19 14:40  资料  短消息  加为好友  添加 mmocom 为MSN好友 通过MSN和 mmocom 交谈
Zend Framework 1.0与 PHP模板引擎SMARTY 的配置



<?php
/**
*
* Zend Framework 与 PHP模板引擎SMARTY 的配置
*
*
*/
require_once 'Smarty/Smarty.class.php';

class Custom_View_Smarty implements Zend_View_Interface
{
        /**
         * Smarty object     
         * @var Smarty     
         */   
        protected $_smarty;
       
        /**
         * Constructor
         *
         * @param string $tmplPath
         * @param array $extraParams
         * @return void
         */   
        public function __construct(array $smartyParams = array())
        {
                //检测SMARTY配置参数是否合格
                $this->_checkRequiredOptions($smartyParams);
               
                $this->_smarty = new Smarty;

            foreach ((array) $smartyParams as $key => $value)
                {
                    $this->_smarty->$key = $value;
            }
        }
        /**     
         * Return the template engine object     
         * 返回模板引擎对象   
         * @return Smarty     
         */   
        public function getEngine()   
        {      
                 return $this->_smarty;   
        }
       
       
        public function setScriptPath($path)   
        {      
        }
       

    public function getScriptPaths()
        {
        }

    /**
     * Set a base path to all view resources
     *
     * @param  string $path
     * @param  string $classPrefix
     * @return void
     */
    public function setBasePath($path, $classPrefix = 'Zend_View')
        {
        }

    /**
     * Add an additional path to view resources
     *
     * @param  string $path
     * @param  string $classPrefix
     * @return void
     */
    public function addBasePath($path, $classPrefix = 'Zend_View')
        {
        }
        /**     
         * 设置模板路径     
         *     
         * @param string $path The directory to set as the path.     
         * @return void     
         */
        public function setTemplatePath()
        {
                if (is_readable( $this->_smarty->template_dir ))
                {            
                        return $this->_smarty->template_dir;
                }
                throw new Exception('Invalid TemplatePath provided');
        }  
        /**     
         * 设置模板编译路径     
         *     
         * @param string $path The directory to set as the path.     
         * @return void     
         */
        public function setCompilePath()
        {
                if (is_readable( $this->_smarty->compile_dir))
                {            
                        return $this->_smarty->compile_dir;
                }
                throw new Exception('Invalid CompilePath provided');
        }
       
        public function getTemplatePath()
    {
        return $this->_smarty->template_dir;
    }   
       
        /**     
         * 分配变量给模板 Assign a variable to the template     
         *     
         * @param string $key The variable name.     
         * @param mixed $val The variable value.     
         * @return void     
         */   
        public function __set($key, $val)   
        {        
                $this->_smarty->assign($key, $val);   
        }   
        /**     
         * Retrieve an assigned variable     
         *     
         * @param string $key The variable name.     
         * @return mixed The variable value.     
         */   
        public function __get($key)   
        {        
                return $this->_smarty->get_template_vars($key);   
        }   
        /**     
         * Allows testing with empty() and isset() to work     
         *     
         * @param string $key     
         * @return boolean     
         */                   
        public function __isset($key)   
        {        
                return (null !== $this->_smarty->get_template_vars($key));   
        }   
        /**     
         * Allows unset() on object properties to work     
         *     
         * @param string $key   
         * @return void     
         */   
        public function __unset($key)   
        {        
                $this->_smarty->clear_assign($key);   
        }   
        /**     
         * 分配变量给模板 Assign variables to the template   
         *     
         * Allows setting a specific key to the specified value, OR passing an array     
         * of key => value pairs to set en masse.     
         *     
         * @see __set()     
         * @param string|array $spec The assignment strategy to use (key or array of key   
         * => value pairs)     
         * @param mixed $value (Optional) If assigning a named variable, use this     
         * as the value.     
         * @return void     
         */   
        public function assign($spec, $value = null)   
        {        
                if (is_array($spec))
                {            
                        $this->_smarty->assign($spec);            
                        return;        
                }        
                $this->_smarty->assign($spec, $value);   
        }   
        /**     
         * 清楚所有已经分配变量 Clear all assigned variables     
         *     
         * Clears all variables assigned to Zend_View either via {@link assign()} or     
         * property overloading ({@link __get()}/{@link __set()}).     
         *     
         * @return void     
         */   
        public function clearVars()   
        {        
                $this->_smarty->clear_all_assign();   
        }   
        /**     
         * 处理模板并返回输出的内容 Processes a template and returns the output.     
         *     
         * @param string $name The template to process.     
         * @return string The output.     
         */   
        public function render($name)   
        {        
                return $this->_smarty->fetch($name);   
        }
       
        /**     
         * 处理模板并显示输出内容 Processes a template and display the output.     
         *     
         * @param string $name The template to process.     
         * @return string The output.     
         */        
        public function display($name)   
        {        
                return $this->_smarty->display($name);   
        }
       
       
         /**
     * Check for extraParams options that are mandatory.
         * 检测 extraParams 的参数项
     * Throw exceptions if any are missing.
     * 抛出错误异常
     * @param array $extraParams
     * @throws Zend_View_Exception
     */
    protected function _checkRequiredOptions(array $extraParams)
    {
        // we need at least a template_dir and compile_dir
        if (! array_key_exists('template_dir', $extraParams)) {
            require_once 'Zend/View/Exception.php';
            throw new Zend_View_Exception("Configuration array must have a key for 'template_dir' for Smarty View.",$this);
        }

        if (! array_key_exists('compile_dir', $extraParams)) {
            /**
             * @see Zend_View_Exception
             */
            require_once 'Zend/View/Exception.php';
            throw new Zend_View_Exception("Configuration array must have a key for 'compile_dir' for Smarty Compile.",$this);
        }

    }
       
}

?>


顶部
zhuzhiwu
新手上路
Rank: 1



UID 162
精华 0
积分 0
帖子 2
翻译 0
原创 0
阅读权限 10
注册 2007-7-8
状态 离线
发表于 2007-8-3 18:02  资料  短消息  加为好友 
写的相当的好啊,一看就是高手,就是不知道杂用,可否简单说说

顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2008-12-3 06:07

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.028311 second(s), 7 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver