首頁 >後端開發 >php教程 >ThinkPHP视图模型指定数据库无效?

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-07-06 13:53:101029瀏覽

<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