create() 无法将post的数据压入.只能压入自动完成的

浏览:557 发布日期:2013/09/05 分类:求助交流
 <?php
 class PhoneAction extends commAction {
    public function update() {
        if (!$this->checkLogin()) {
            setcookie('key', '', time() - 3600);
            $this->error('未登录', '/');
        }
        $phone = D('Phone');
        $result = $phone->db(1, 'DB_CONFIG1')->create();
        print $result;
        if (!$result) {
            $this->error($phone->getError());
        }
        if ($phone->db(1, 'DB_CONFIG1')->add()) {
            $this->success('修改成功', '/');
        } else {
            $this->error('修改失败','/');
        }
    }
 }
 ?>
帮忙看看这代码 <?php
 class PhoneModel extends Model {
    protected $_validate = array(
        array('youPhone','11,11','手机号长度错误','1','length'),
        array('showPhone','11,11','手机号长度错误','1','length')
    );
    protected $_auto = array (
        array (
            'ip',
            'getIp',
            1,
            'callback'
        ),
        array (
            'addUser',
            'getUser',
            1,
            'callback'
        ),
        array (
            'userAgent',
            'getUserAgent',
            1,
            'callback'
        ),
        array (
            'addTime',
            'time',
            1,
            'function'
        )
    );
    public function getUserAgent() {
        return $_SERVER['HTTP_USER_AGENT'];
    }
    public function getUser() {
        return $_SESSION['username'];
    }
    public function getIp() {
        static $realip;
        if (isset ($_SERVER)) {
            if (isset ($_SERVER["HTTP_X_FORWARDED_FOR"])) {
                $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
            } else
                if (isset ($_SERVER["HTTP_CLIENT_IP"])) {
                    $realip = $_SERVER["HTTP_CLIENT_IP"];
                } else {
                    $realip = $_SERVER["REMOTE_ADDR"];
                }
        } else {
            if (getenv("HTTP_X_FORWARDED_FOR")) {
                $realip = getenv("HTTP_X_FORWARDED_FOR");
            } else
                if (getenv("HTTP_CLIENT_IP")) {
                    $realip = getenv("HTTP_CLIENT_IP");
                } else {
                    $realip = getenv("REMOTE_ADDR");
                }
        }
        return $realip;
    }
 }
 ?>    
为啥create没接收到表单的值... 返回的数组只有自动完成的? 还有D方法该怎么自定义前缀,在config 里面已经定义了'DB_PREFIX' => 'sip_',但还是使用think


最佳答案
评论( 相关
后面还有条评论,点击查看>>