Sae上使用一輕量ORM庫 idiorm的問題。
本人小菜,發現一個好用的輕量orm庫idiorm,純粹是覺得方便加上怕自己寫的東西會有安全性問題所以想用這個。
他的文檔如下:http://idiorm.readthedocs.org/en/latest/index.html
Github中地址: https://github.com/j4mie/idiorm
Index.php代碼如下:
require_once "ORM.php";
ORM::configure('mysql:host=localhost;dbname=mydemotest');
ORM::configure('username', 'root');
ORM::configure('password', '123456');
//初始化
ORM::configure('return_result_sets', true);
//
$account = ORM::for_table('account')->create();
$account->id = 11;
$account->account = 1236;
$account->save();
分別用的就是其文檔上的:
以上這段代碼在我本地的xampp上可以運行
但是放到sae上就有問題
我的sae下首先自己建立了一個資料庫,表名是account
然後在我的目錄下遊這兩個檔案,(ORM就是那個idiorm庫)
對應index.php中的代碼是:
require_once 'ORM.php';
ORM::configure('mysql:host=w.rdc.sae.sina.com.cn:3307;dbname=SAE_MYSQL_DB');
ORM::configure('username', 'SAE_MYSQL_USER');
ORM::configure('password', 'SAE_MYSQL_PASS');
$account = ORM::for_table('account')->create();
$account->id = 11;
$account->account = 1236;
$account->save();
?>
然後就出現以下問題:
所以就想請教下各位前輩,自己也百度了很久,實在本人知識水平有限。
謝謝
------解決思路----------------------
SAE_MYSQL_XXXX 是常量!
ORM::configure('mysql:host=w.rdc.sae.sina.com.cn:3307;dbname=' . SAE_MYSQL_DB);
ORM::configure('username', SAE_MYSQL_USER);
ORM::configure('password', SAE_MYSQL_PASS);
另外,主機名稱、連接埠名也應用它提供的常量 SAE_MYSQL_HOST_M、SAE_MYSQL_PORT