1
//here is my function block
public function create_accnt()
{
    $post = $this->input->post(); //gets all possible posts in array form

    echo "Post array: ";print_r($post); // just to make sure that my array has    values

    $data = array(
        'userid'    => $post['user_id'],
        'lastname'  => $post['lname'],
        'firstname' => $post['fname'],
        'username'  => $post['username'],
        'password'  => $post['password'],
        'usertype'  => $post['user_type'],
        'status'    => 'A'
    ); // assigning my values to their specific fields where they will be inserted

    $query = $this->db->insert('accounts', $data); //insertion via active record

    echo "<br/>Result of db last query: "; 
    echo $this->db->last_query();//to see how my query looks in code form

    if($query)
    {
        return true;
    }
    else
        return false;
    // end if
} // end function

//here is the result of the code above

//Post array: Array ( [user_id] => 123456 [lname] => Smith [fname] => John [username] =>     John [password] => password [c_password] => password [user_type] => S [btn_create] => Create )

//Result of db last query: INSERT INTO accounts (userid, lastname, firstname, username, password, usertype, status) VALUES ('', '', '', '', '', '', '')

这里为什么在查询后我的 VALUES 都是空格?顺便说一句,我正在使用 CodeIgniter,我的数据库驱动程序是 PDO,我的数据库是 DBFoxPro。

4

2 回答 2

1

我最终使用$this->db->query()了 CI 的功能并手动提供了我的查询语句。我认为$this->db->insert()不会通过 PDO 驱动程序在我的 db DBF-foxpro 上工作。我也有关于$this->db->where()功能的问题。现在我只是在使用$this->db->query(). 谢谢你的帮助。

于 2013-04-19T00:36:08.973 回答
0

代替

 $data = array(
        'userid'    => $post['user_id'],
        'lastname'  => $post['lname'],
        'firstname' => $post['fname'],
        'username'  => $post['username'],
        'password'  => $post['password'],
        'usertype'  => $post['user_type'],
        'status'    => 'A'
    );

利用

$data = array(
        'userid'    => $this->input->post('user_id'),
        'lastname'  => $this->input->post('lname'),
        'firstname' => $this->input->post('fname'),
        'username'  => $this->input->post('username'),
        'password'  => $this->input->post('password'),
        'usertype'  => $this->input->post('user_type'),
        'status'    => 'A'
    );
于 2013-04-18T06:48:59.027 回答