为什么我的变量在Codeigniter中从Controller传递给Model时会损坏

时间:2013-01-22 15:09:36

标签: php codeigniter

我生气了。

我将一个变量从Controller方法传递给Method,不知怎的,它在传输过程中发生了变化。最初它被愚蠢地称为$id ..因此我认为可能存在一些可变干扰..但我已更改名称并且问题仍然存在。

谁能告诉我可能会发生什么?

这是代码..检查我的评论

public function firstFbLogin()
{
    ChromePhp::log('AJAX - first FB login');  // logs fine
    $username          = $this->input->post('username');
    $first_name        = $this->input->post('first_name');
    $last_name         = $this->input->post('last_name');
    $facebookId        = $this->input->post('facebookId');
    $email             = $this->input->post('email');
    $third_party_id    = $this->input->post('third_party_id');
    $gender         = $this->input->post('gender');
    $this->Member_model->mFirstFbLogin($username, $first_name, $last_name, $email, $facebookId, $third_party_id, $gender);
            // here comes the issue..
    $idFromFbDooDaDay = $this->Member_model->mFetchIdFromFacebook($facebookId);
    ChromePhp::log("Id found and going out of ajax - firstFbLogin is ". $idFromFbDooDaDay); // <<< this logs 232 which is what I am expecting
    $this->Member_model->mCreateProfilePage($username, $first_name, $last_name, $idFromFbDooDaDay, $third_party_id, $gender);
    echo "TRUE";
}

但是在我的Member_model上我有了这个(我会编辑一堆)

    public function mCreateProfilePage($username, $first_name, $last_name, $gender, $idFromFbDooDaDay, $third_party_id)
    {
        // lets create a 'profile.html' used for FB object interaction
        $this->load->helper('file');
        ChromePhp::log('Id coming into mCreateProfilePage is ' . $idFromFbDooDaDay);  // this logs as D0k9f7LxtjIHMhGnbn6UkhDk3ao  WTF!?!
        $data = "<html>\n";
        $data .= "<head prefix=\"og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# profile: http://ogp.me/ns/profile#\">\n";
        $data .= "<meta property=\"fb:app_id\" content=\"32xxxxxxxxxxxx6\" />\n"; // my APP ID
        $data .= "<meta property=\"og:type\"   content=\"profile\" />\n";  // stays profile
        $data .= "<meta property=\"og:url\"    content=\"www.MYSITE.com/profiles/id-".$idFromFbDooDaDay."\" />\n"; // put the URL
        $data .= "<meta property=\"og:image\"  content=\"https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png\" />\n";  // url to bigPic

 ... edit ...

        $file_path = 'profiles/id-' . $idFromFbDooDaDay . '.html';

        if (!write_file($file_path, $data))
        {
             ChromePhp::log('Problem writing profile');
        }
        else
        {
             ChromePhp::log('Profile written to '. $file_path);
        }
    }

那么$idFromFbDooDaDay = 232如何在从控制器到模型的简单传递范围内变成$idFromFbDOoDaDay = D0k9f7LxtjIHMhGnbn6UkhDk3ao的27个字符的噩梦?

它不能是可变干扰..就我所知,没有别的东西可以触及var。怎么了?

1 个答案:

答案 0 :(得分:5)

// $this->Member_model->
mCreateProfilePage($username, $first_name, $last_name, $idFromFbDooDaDay, $third_party_id, $gender);
// public function 
mCreateProfilePage($username, $first_name, $last_name, $gender, $idFromFbDooDaDay, $third_party_id)

你的论点不匹配,这可能是原因:)