~~~
//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