下载ecshop后,解压缩,进入目录upload/includes,复制里面的cls_mysql.php放进你自己的网站
比如我的目录结构
/ /Classes /Classes/cls_mysql.php /Classes/connfig.php /index.php
在/Classes目录里新建connfig.php文件,代码如下
<?php header("Content-Type:text/html;charset=utf-8"); date_default_timezone_set("Etc/GMT-8"); error_reporting(E_ALL ^ E_NOTICE); define(‘IN_ECS‘, true); define(‘EC_CHARSET‘, ‘utf-8‘); define(‘ROOT_PATH‘, dirname(__FILE__).‘\..\\‘); define(‘DATA_DIR‘, ‘data‘); $db_host = "localhost:3306"; $db_name = "test"; $db_user = "root"; $db_pass = ""; require(ROOT_PATH.‘Classes/cls_mysql.php‘); $db = new cls_mysql($db_host, $db_user, $db_pass, $db_name); ?>
根目录下的index.php文件代码如下
<?php global $db; require_once ‘Classes/connfig.php‘; $sql = ‘SELECT id FROM table WHERE uid=‘1‘; $row = $db->getOne($sql); echo $row; ?>
时间: 2024-11-10 13:39:55