PHP 基礎問題

1、zend_framework 要自己配置一邊,CSS和JS最好放在public 目錄下。 ZF的目錄結構需要清除知道,可以不用默認目錄結構。 需要使用ZF組件時,需要用require_once加載zend目錄下相應PHP文件。

 

2、花費時間最多的是鏈接數據庫。其中鏈接了oracle10,sqlserver2000,mysql5.6
       a)  oracle10因為客戶端也是oracle10,基本的是用PDO_OCI鏈接,PDO_OCI8是鏈接就版本
       b) sqlserver2000,太老的版本了,PDO支持不是很好,odbc鏈接就無法使用ZF。
            PDO_mssql有很大bug,會截斷text類型欄位。微軟自己開發的sqlsrv還在測試版本,安裝時需要安裝一大堆.net支持。對sqlserver2005以上版本支持。
       c) 無奈之下,將sqlserver2000中的數據導入到mysql5.6中。使用工具mssql to mysql 。 網上有破解,官網只有demo版,只能導5筆記錄。
          開始時使用mysql migration tookit ,也有bug,裝了jre,老提示無法加載。最後只能用dos進入安裝目錄。用程序名 -debug打開。默認情況下只能
         看到sqlserver2000 上鏈接時,使用名稱的默認數據庫。沒有導數據成功。強烈建議用mssql to mysql ,csdn上有mss2sql_v5-3.zip。雖然不是最新版,但已破解,很好用
     d)mysql5.6 默認字符集不是中文字符集,網上修改my.ini方法都不好用,都是針對低版本的。此版本可以在my.ini 下[mysqld]節,加入
        character-set-server =  big5  (此為繁體,根據需要自己修改)測試,中文ok
3、ZF很好用,配置比較麻煩。
    config.ini 
  [production]
bootstrap.path=HOME_PATH"/Bootstrap.php"
bootstrap.class="Bootstrap"
resources.frontController.controllerDirectory=HOME_PATH"/controllers"
[general]
db.adapter = PDO_Oci                oracle數據庫
db.config.host = 192.168.1.11
db.config.username =test
db.config.password = test
db.config.dbname = oracle
[myhost]                                        sqlserver2000    PDO5.0不支持,沒有響應的dll文件
db.adapter = PDO_mssql
db.config.host = localhost
db.config.username = sa
db.config.password =
db.config.dbname = Northwind
[mysql]                                    mysql數據庫
db.adapter = PDO_mysql
db.config.host = 127.0.0.1
db.config.username = root
db.config.password = d2PUKu6ynAyGNnzM
db.config.dbname = sqlexe
引導文件index.php

<?php
defined('LIBRARY_PATH')||define('LIBRARY_PATH', realpath(dirname(__FILE__).'/../lib'));      定義'LIBRARY_PATH全局變量,類似,都是路徑,以後用起來方便。

<?php
defined('LIBRARY_PATH')||define('LIBRARY_PATH', realpath(dirname(__FILE__).'/../lib'));
defined('HOME_PATH')||define('HOME_PATH',realpath(dirname(__FILE__).'/../home'));
defined('CONFIGS_PATH')||define('CONFIGS_PATH',realpath(dirname(__FILE__).'/../configs'));
defined('APPLICATION_ENV')||define('APPLICATION_ENV', (getenv('APPLICATION_ENV')?
getenv('APPLICATION_ENV'):'production'));
set_include_path(implode(PATH_SEPARATOR,array(realpath(LIBRARY_PATH),get_include_path())));
require_once (dirname(__FILE__).'\..\lib\Zend\Config\Ini.php');
$config = new Zend_Config_Ini(CONFIGS_PATH.'/configs.ini', 'general');                      配置不同數據庫,對應config.ini響應的[]結構
$configsql = new Zend_Config_Ini(CONFIGS_PATH.'/configs.ini', 'myhost');
$configmysql = new Zend_Config_Ini(CONFIGS_PATH.'/configs.ini', 'mysql');
require_once (dirname(__FILE__).'\..\lib\Zend\Registry.php');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);
$registrysql = Zend_Registry::getInstance();
$registrysql->set('configsql', $configsql);
$registrymysql = Zend_Registry::getInstance();
$registrymysql->set('configmysql', $configmysql);
require_once (dirname(__FILE__).'\..\lib\Zend\Db.php');
$db = Zend_Db::factory($config->db->adapter,$config->db->config->toArray());
$dbsql = Zend_Db::factory($configsql->db->adapter,$configsql->db->config->toArray());
$dbmysql = Zend_Db::factory($configmysql->db->adapter,$configmysql->db->config->toArray());
require_once (dirname(__FILE__).'\..\lib\Zend\Db\Table.php');
Zend_Db_Table::setDefaultAdapter($db);
$registry->set('db', $db);
Zend_Db_Table::setDefaultAdapter($dbsql);
$registry->set('dbsql', $dbsql);
Zend_Db_Table::setDefaultAdapter($dbmysql);
$registry->set('dbmysql', $dbmysql);

require_once (dirname(__FILE__).'\..\lib\Zend\Application.php');

$application=new Zend_Application(APPLICATION_ENV,CONFIGS_PATH.'/configs.ini');

$application->bootstrap()->run();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值