zend framework_v1 常见问题汇总

一、配置虚拟主机以后,Action没法正常工做,缘由为没有开启AllowOverride。 php

初始配置: html

<VirtualHost 127.0.0.1:80>
    DocumentRoot "E:/PHP/votesystem001/public"
    ServerName zendvote.com
    DirectoryIndex index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不容许别人修改咱们的页面
    AllowOverride None
    #设置访问权限
    order allow,deny
    Allow from all
    </Directory>
</VirtualHost> mysql

修改成: sql

<VirtualHost 127.0.0.1:80>
    DocumentRoot "E:/PHP/votesystem001/public"
    ServerName zendvote.com
    DirectoryIndex index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不容许别人修改咱们的页面
    AllowOverride All
    #设置访问权限
    order allow,deny
    Allow from all
    </Directory>
</VirtualHost> app

二、中文乱码问题 ide

若是本网站的内容只是在国内公开,也就是说,只要支持中文便可,能够经过下面的设置解决中文乱码: 工具

1>在mysql建立表的时候,写明编码为gbk; 网站

CREATE TABLE `vote_log` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `ip` varchar(20) NOT NULL,
  `vote_date` bigint(20) NOT NULL,
  `item_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk; 编码

2>所用的代码编辑工具,设置编码为GBK; url

3>初始化适配器的时候,指明为GBK;

$url = constant("APPLICATION_PATH").DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR.'application.ini';
      $dbconfig = new Zend_Config_Ini($url,"mysql
      $db = Zend_Db::factory($dbconfig->db);
      $db->query('SET NAMES GBK');
      Zend_Db_Table::setDefaultAdapter($db);

完成以上三步以后,你的中文乱码问题,也就解决了。

总结:目的就是要保证编码要统一。

相关文章
相关标签/搜索