本人小菜,发现一个好用的轻量orm库idiorm,纯粹是觉得方便加上怕自己写的东西会有安全性问题所以想用这个。
他的文档如下:http://idiorm.readthedocs.org/en/latest/index.html
Github中地址: https://github.com/j4mie/idiorm
Index.php代码如下:
<?phprequire_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();
<?phprequire_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);