3.2.3下oracle表模型出错,请指点【已解决】

浏览:694 发布日期:2014/12/26 分类:求助交流
链接oracle的配置文件如下<?php
return array (
        'CONFIG_DB_ORACLE' => array (
                'DB_TYPE' => 'oracle',
                'DB_HOST' => '192.168.1.3',
                'DB_NAME' => 'csk',
                'DB_USER' => 'system',
                'DB_PWD' => '123456',
                'DB_PORT' => '1521',
                'DB_PREFIX' => '',
                'DB_DSN' => '',
                'DB_CHARSET' => 'utf8',
                'DB_CASE_LOWER' => "true"  // 改变结果集字段值为小写
                ) 
);
以下是正常代码,可查出数据$DB_CONFIG = C ( 'CONFIG_DB_ORACLE' );
        $model = new Model ( 'sex_dict', null, $DB_CONFIG );
        $map ['sex_dict.SEX_NAME'] = '男';
        $result = $model->where ( $map )->select ();
        
        dump ( $result );
上面是可以显示表记录的

以下代码是模型 SexDictModel.class.php<?php

namespace _Public\Model;

use Think\Model;

class SexDictModel extends Model {
    
    /**
     * 设定真实表名
     */
    protected $trueTableName = 'sex_dict';
    
    /**
     * 由主键得到表的一条记录
     * 输入主键的值
     * 返回值: 数组或布尔型false
     */
    public function get_info_by_SEX_NAME($SEX_NAME) {
        $DB_CONFIG = C ( 'CONFIG_DB_ORACLE' );
        $model = new Model ( 'sex_dict', null, $DB_CONFIG );
        $map ['sex_dict.SEX_NAME'] = $SEX_NAME;
        $result = $model->where ( $map )->select ();
        
        if ($result == null) {
            $result = false;
        } else {
            
            $result = $result [0];
        }
        
        return $result;
    }
}
下面在调用模型的时候会出错:<?php

namespace Setup\Controller;

use _Public\Model\SexDictModel;
use Think\Model;

class TestController extends BaseController {
    public function index() {
        $tt = new SexDictModel(); //这一行出错
        

        
        // 显示模板
        $this->display ( 'Test:test' );
    }
}
出错信息为: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'abis_test.sex_dict' doesn't exist in D:\wamp\www\abis_kk\ThinkPHP\Library\Think\Db\Driver.class.php on line 167我项目中的mysql数据库名为:abis_test

以上代码在3.2.2中完全正常,请指点一下,多谢了!

最佳答案
评论( 相关
后面还有条评论,点击查看>>