~~~
//todo 读取数据库字段 start
if (empty($this->config['database'])) {
$configFile = APP_PATH . "data/common.inc.php";
if (!file_exists($configFile)) {
$dir_handle = opendir(APP_PATH);
while (($file = readdir($dir_handle)) !== false) {
if (substr($file, 0, 1) !== '.' and is_dir(APP_PATH . $file)) {
$dir_handle2 = opendir(APP_PATH . $file);
while (($file2 = readdir($dir_handle2)) !== false) {
if ($file2 === 'common.inc.php') {
$filePath = APP_PATH . $file . '/' . $file2;
$content = file_get_contents($filePath);
if (strpos($content, '//数据库连接信息') !== false) {
$configFile = $filePath;
break 2;
}
}
}
closedir($dir_handle2);
}
}
closedir($dir_handle);
}
if (!file_exists($configFile)) {
res(1002, "接口配置异常,无法正常读取配置信息");
}
$cfg_dbhost = $cfg_dbuser = $cfg_dbpwd = $cfg_dbname = $cfg_db_language = $cfg_dbprefix = '';
require_once($configFile);
$hostArr = explode(":", $cfg_dbhost);
$this->config['database'] = array(
'host' => $hostArr[0],
'port' => $hostArr[1] ? $hostArr[1] : '3306',
'user' => $cfg_dbuser,
'password' => $cfg_dbpwd,
'database' => $cfg_dbname,
'charset' => $cfg_db_language,
'prefix' => $cfg_dbprefix
);
}
if (!$this->config['setting']['product_model_id']) {
$this->config['setting']['product_model_id'] = 6;
}
//todo 读取数据库字段 end
~~~
- 序言
- 初始化
- 开发说明
- main.php
- connectProvider例子
- dedecms
- wordpress
- provider.php
- 方法说明
- getCategories获得分类列表
- getPosts获得数据列表
- getProducts获得产品列表
- getArticles获得文章列表
- getArticle获得文章详情
- getProduct获得产品详情
- getPages获得单页列表
- getPage获得单页详情
- getComments获得评论列表
- saveComment新增/修改评论
- commentAttitude点赞或反对评论
- getParams获得扩展字段
- getMapping获得sitemap
- getSiteMapIndex获得sitemapIndex