首页 >后端开发 >php教程 >ThinkPHP视图模型指定数据库无效?

ThinkPHP视图模型指定数据库无效?

WBOY
WBOY原创
2016-07-06 13:53:101000浏览

<code><?php namespace Common\Model;

/**
 * 无法使用
 */
class MessageViewModel extends \Think\Model\ViewModel {

    protected $connection = "DB_CONF_MAN";

    protected $viewFields = array(
        "Message" => array(
            "*",
            "_type" => "LEFT",
        ),
        "MessageText" => array(
            "title",
            "content",
            "_on" => "Message.message_text_id = MessageText.id",
        )
    );

}
</code>
ps:普通模型指定$connection能正常操作指定数据库

回复内容:

<code><?php namespace Common\Model;

/**
 * 无法使用
 */
class MessageViewModel extends \Think\Model\ViewModel {

    protected $connection = "DB_CONF_MAN";

    protected $viewFields = array(
        "Message" => array(
            "*",
            "_type" => "LEFT",
        ),
        "MessageText" => array(
            "title",
            "content",
            "_on" => "Message.message_text_id = MessageText.id",
        )
    );

}
</code>
ps:普通模型指定$connection能正常操作指定数据库

没用过,,路过

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn