Mysql Insert Operation


Insert new records in a table using associative array. Instead of writing long insert queries, you needs to pass array of keys(columns) and values(insert values). This function will automatically create query for you and inserts data.

Function Reference :
          		void dbInsert(string $table_name, assoc. array $insert_array); 


Name Type Required Parameter Info Example
table_name string Yes The name of the table to insert new records any table name like employee_table,user_table
insert_array associative array Yes Associative array with key as column name and values as column value. array("username"=>"abcd","gender"=>"male","age"=>29)


            $sdb= new SimplifiedDB();
            $sdb->dbInsert("user_roles",array("role_name"=>"Contributer","role_description"=>"Contribues for the system")); 


New row will be inserted in table.


Debug Operation Result/Output
$sdb->query INSERT INTO `user_roles`(`role_name`,`role_description`) VALUES ('Contributer','Contribues for the system')
$sdb->last_insert_id 32
$sdb->rows_affected 1
$sdb->message_info Connected to database

More Examples

            $insertRoles["role_description"]="Manages system";