Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Save array in database and miss data

I need to save in database category like "a & b" but the model save in database just "a" miss the blank space and the &.

This is the array:

$data = array('avenvu'        => $_POST['avenvu'],
              'brand'         => $_POST['brand'],
              'category'      => $_POST['category'],
              'description'   => $_POST['description'],
              'man_women_shop'=> $_POST['man_women_shop'],
              'postdatetime'  => date("Y-m-d H:i:s",time()), 
              'publish'       => 1,  
              'user_id'       => $this->session->userdata('user_id'));

$result = $this->personal_closest->insertCloset($data);

And this is the model:

function insertCloset($data) {
    $this->db->insert('personal_closest',$data);
}
like image 936
davidev Avatar asked Apr 18 '15 09:04

davidev


1 Answers

Change your insertCloset function:

function insertCloset($data) {

    $personal['avenvu']         =  $data['avenvu'];
    $personal['brand']          =  $data['brand'];
    $personal['category']       =  $data['category'];
    $personal['description']    =  $data['description'];
    $personal['man_women_shop'] =  $data['man_women_shop'];
    $personal['postdatetime']   =  $data['postdatetime'];
    $personal['publish']        =  $data['publish'];
    $personal['user_id']        =  $data['user_id'];

    $this->db->insert('personal_closest',$personal);
}
like image 112
Sathya Baman Avatar answered Nov 15 '22 18:11

Sathya Baman