> 是指系統框架內的類操作
### 框架內置數據庫操作
**添加數據**
~~~
/**
* 添加數據
*/
$data = array(
'port' => $port,
'type' => 'port',
'ps' => $ps,
'addtime' => date('Y-m-d H:i:s')
);
//正常添加
cp::db('table')->add($data);
~~~
更多詳細操作參考 [數據庫操作](數據庫操作.md)
*****
### URL請求處理
**輸出當前目錄結構**
例如請求地址為 `http://www.cmspro.cn/index/test`
```
var_dump(cp::url());
```
打印輸出為
```
array(3) {
[0]=>
string(15) "www.cmspro.cn"
[1]=>
string(5) "index"
[2]=>
string(5) "test"
}
```
單獨輸出當前域名
```
echo cp::url()[0]; //輸出為當前請求的域名www.cmspro.cn
```
輸出一級目錄
```
echo cp::url()[1]; // 當前請求的一級目錄 index
```
輸出二級目錄
```
echo cp::url()[2]; // 當前請求的一級目錄 test
```
依次類推
**輸出當前http或https**
例如請求地址為 `http://www.cmspro.cn/index/test`
```
echo cp::url('h'); //輸出為 http
```
例如請求地址為 `https://www.cmspro.cn/index/test`
```
echo cp::url('h'); //輸出為 https
```
**輸出當前請求的域名**
和`echo cp::url()[0];` 相同效果
例如請求地址為 `http://www.cmspro.cn/index/test`
```
echo cp::url('d'); //輸出為 www.cmspro.cn
```
**輸出當前GET請求信息**
例如請求地址為 `www.shiyong.com/index/index?a=1&b=2`
```
var_dump(cp::url('g'));
```
打印數組為
```
array(2) {
["a"]=>
string(1) "1"
["b"]=>
string(1) "2"
}
```
就可以這么單獨輸出
```
echo cp::url('g')['a']; //輸出為 1
echo cp::url('g')['b']; //輸出為 2
```
也可以用PHP內置的`$_GET`
例如
```
echo $_GET['a']; //輸出為 1
echo $_GET['b']; //輸出為 2
```
**輸出當前POST請求信息**
例如發送的請息為
```
array(2) {
["a"]=>
string(1) "1"
["b"]=>
string(1) "2"
}
```
就可以這么單獨輸出
```
echo cp::url('p')['a']; //輸出為 1
echo cp::url('p')['b']; //輸出為 2
```
也可以用PHP內置的`$_POST`
例如
```
echo $_POST['a']; //輸出為 1
echo $_POST['b']; //輸出為 2
```
*****
### 自動附加封裝類、函數入口
把對應的類或方法文件以 `xxx.lib.php`形式放入 `\cmspro\lib\`中,例如:郵件操作 `\cmspro\lib\email.lib.php`
使用方法
~~~
//引入郵件類
$_cp->re('email');
~~~