我的目标是使用CodeIgniter数据库类,但在一个普通的PHP脚本中。 我不想为此使用MVC结构。如何使用不带codeIgniter MVC框架的数据库codeigniter类?
我可以使用这个数据库类没有使用CodeIgniter MVC模式?
如果是,如何?
我的目标是使用CodeIgniter数据库类,但在一个普通的PHP脚本中。 我不想为此使用MVC结构。如何使用不带codeIgniter MVC框架的数据库codeigniter类?
我可以使用这个数据库类没有使用CodeIgniter MVC模式?
如果是,如何?
请按照下面的步骤来整合笨DB的Active Record以下文件
application/config/config.php
application/config/database.php
system/database/*
system/core/Common.php
system/core/Exceptions.php
system/core/Log.php
复制的目录结构是如上述
application/config/database.php
创建数据库连接(connector.php)文件
<?php
defined('DS') OR define('DS', DIRECTORY_SEPARATOR);
defined('EXT') OR define('EXT', '.php');
defined('ENVIRONMENT') OR define('ENVIRONMENT', 'development');
$dir_path = dirname(__FILE__) . DS;
defined('BASEPATH') OR define('BASEPATH', $dir_path . 'system' . DS);
defined('APPPATH') OR define('APPPATH', $dir_path . 'application' . DS);
function getDBConnector(){
include_once(BASEPATH . "core/Common.php");
include_once(BASEPATH . "core/Exceptions.php");
require_once(BASEPATH . 'database/DB' . EXT);
$conn = & DB();
return $conn;
}
$db = getDBConnector();
print_r($db->get('users')->result_array());
geeting below ERROR: 致命错误:调用未定义函数get_instance()在G:\ wamp \ www \ CIDB \ system \ core \ Lang.php on line 139 – nilesh 2016-02-06 11:33:11
为什么你想这样做? – j0k 2013-03-09 11:09:28
你可以使用php include来包含db类 – 2013-03-09 11:10:15
这是如何得到3个upvotes的? – Qix 2014-05-13 21:42:17