热搜:NVER node 开发 php

Sae上使用一轻量ORM库 idiorm的问题。

2024-08-20 22:35:01
Sae上使用一轻量ORM库 idiorm的问题。

本人小菜,发现一个好用的轻量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();

分别用的就是其文档上的:



以上这段代码在我本地的xampp上可以运行
但是放到sae上就有问题
我的sae下首先自己创建了一个数据库,表名是account

然后在我的目录下游这两个文件,(ORM就是那个idiorm库)

对应index.php中的代码是:
<?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);


另外,主机名、端口名也应用它提供的常量 SAE_MYSQL_HOST_M、SAE_MYSQL_PORT