namespace home\model;use think\model;class categorymodel extends model { protected $truetablename = 'top_categories'; protected $dbname = 'top';}
$mymodel = new categorymodel ();//id为主键$data = array('num'=>1,'id '=> 1);$status = $mymodel->save($data);//或者$data = array('num'=>1);$status = where(array('id'=> 1))->save($data);
返回的$status都是0,为什么?
回复内容: thinkphp操作当前数据库以外的数据表时,发现更新字段的时候返回0,是跨库就不没有写入权限了么?
namespace home\model;use think\model;class categorymodel extends model { protected $truetablename = 'top_categories'; protected $dbname = 'top';}
$mymodel = new categorymodel ();//id为主键$data = array('num'=>1,'id '=> 1);$status = $mymodel->save($data);//或者$data = array('num'=>1);$status = where(array('id'=> 1))->save($data);
返回的$status都是0,为什么?
$mymodel = new categorymodel ();
实例化模型不是用d方法么。。。
已经解决了。
thinkphp跨库调用
