~~~
//todo 讀取數據庫字段 start
if (empty($this->config['database'])) {
$configFile = APP_PATH . "wp-config.php";
if (!file_exists($configFile)) {
res(1002, "接口配置異常,無法正常讀取配置信息");
}
$table_prefix = '';
$contents = file_get_contents($configFile);
preg_match('/\$table_prefix\s*=\s*[\'|"](.+)[\'|"]/', $contents, $match);
$table_prefix = $match[1];
preg_match('/define\(\s*[\'|"]DB_NAME[\'|"],\s*[\'|"](.+)[\'|"]/', $contents, $match);
$dbName = $match[1];
preg_match('/define\(\s*[\'|"]DB_USER[\'|"],\s*[\'|"](.+)[\'|"]/', $contents, $match);
$dbUser = $match[1];
preg_match('/define\(\s*[\'|"]DB_PASSWORD[\'|"],\s*[\'|"](.+)[\'|"]/', $contents, $match);
$dbPassword = $match[1];
preg_match('/define\(\s*[\'|"]DB_HOST[\'|"],\s*[\'|"](.+)[\'|"]/', $contents, $match);
$dbHost = $match[1];
preg_match('/define\(\s*[\'|"]DB_CHARSET[\'|"],\s*[\'|"](.+)[\'|"]/', $contents, $match);
$dbCharset = $match[1];
$hostArr = explode(":", $dbHost);
$this->config['database'] = array(
'host' => $hostArr[0],
'port' => empty($hostArr[1]) ? '3306' : $hostArr[1],
'user' => $dbUser,
'password' => $dbPassword,
'database' => $dbName,
'charset' => $dbCharset,
'prefix' => $table_prefix
);
}
//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