Ovidiu B
Ovidiu B

Reputation: 106

Codeigniter SQLite Insert not recorded

I am trying to insert records into a DB using CodeIginter and SQLite3, however I am unable to insert them, only to select from database.

I have 777 on the db folder, which includes my test.db file, also using adminer I am able to insert and view records.

This is my method of inserting an array into db:

function insertIntoLP($data){
    $this->load->database();
    return $this->db->insert('landing_pages', $data);
}

The code which is calling the above method is:

$data = array(
            'id'    => '',
            'brand' => $brand,
            'name' => $name,
            'settings' => serialize($settings),
            'date' => time(),
        );

        return $this->dbsql->insertIntoLP($data);

It's returning success but the records are not recorded. Any ideas?

Upvotes: 1

Views: 976

Answers (1)

Debflav
Debflav

Reputation: 1151

I don't know which version of CodeIgniter you are using. But, between the version 2.1.4 and 2.2.0 someone noticed that the file system/database/drivers/pdo/pdo_driver.php" change.

In the current version 2.2.0 an issue has been open and a fix has been given. Maybe you should take a look and keep up-to-date your application.

Your code is correct and you have installed drivers, so I hope it will solve your problem.


After your edition:

Table architecture still missing but I guess your array of $data should be like this:

$data = array(
        'brand' => $brand,
        'name' => $name,
        'settings' => serialize($settings),
        'date' => time(),
);

I've remove the id. If it's defined as auto increment in your database, just remove it from your request.

You was doing:

INSERT INTO landing_pages(id, brand, name, settings, date) VALUES (NULL, 'Some Data', 'Some Data', 'Some Data', 'Date')

But it should work better without id:

INSERT INTO landing_pages(brand, name, settings, date) VALUES ('Some Data', 'Some Data', 'Some Data', 'Date')

Upvotes: 1

Related Questions