Try this
function add_post($post_data){
$this->db->insert('posts', $post_data);
$insert_id = $this->db->insert_id();
return $insert_id;
}
In case of multiple inserts you could use
$this->db->trans_start();
$this->db->trans_complete();
More Related Contents:
- Codeigniter – multiple database connections
- UNION query with codeigniter’s active record pattern
- How would I use ON DUPLICATE KEY UPDATE in my CodeIgniter model?
- Delete the entire content of all table in a Database [closed]
- MyISAM versus InnoDB [closed]
- Delete all Duplicate Rows except for One in MySQL? [duplicate]
- MySQL string replace
- What is the difference between utf8mb4 and utf8 charsets in MySQL?
- How do I find the MySQL my.cnf location
- What’s faster, SELECT DISTINCT or GROUP BY in MySQL?
- MySQL select one column DISTINCT, with corresponding other columns
- How to use mysql JOIN without ON condition?
- How to remove all non-alpha numeric characters from a string in MySQL?
- Define a variable within select and use it within the same select
- ERROR: Error 1005: Can’t create table (errno: 121)
- Mysql Convert Column to row (Pivot table )
- Merge two tables in one SQL query and make the date values unique
- How to get all columns’ names for all the tables in MySQL?
- How to fix double-encoded UTF8 characters (in an utf-8 table)
- How to integrate ElasticSearch with MySQL?
- How to change MySQL table names in Linux server to be case insensitive?
- MySQL command line formatting with UTF8
- MYSQL select DISTINCT values in two columns
- MySQL LOAD_FILE() loads null values
- MySQL Select ID’s which occur on different rows with multiple specific values for a column
- Use promise to process MySQL return value in node.js
- where does MySQL store database files?
- How can I achieve initcap functionality in MySQL?
- MySQL “ERROR 1005 (HY000): Can’t create table ‘foo.#sql-12c_4’ (errno: 150)”
- Dump only the data with mysqldump without any table information?