How to insert an auto-increment id data table that is already set to auto-increment.
// Insert_arr (table name, field name, insert value) --- "get the array inserted into the database // public function insert_arr ($ tab_name, $ tab_filed =" ", $ insert_arr ){}
}
Whether to insert full fields or select fields.
If (omitted ){
When a table has more than 10 fields, it seems that this process is omitted, but how to give the value to the auto-increment ID field.
When the table structure is modified later, the code certainly reports an error when the field is sorted or added.
} Else {
I have to write more than 10 fields in a table. in the future, the table should not be modified. Is it too lazy ....
}
Reply to discussion (solution)
The auto-increment field can be default, or you can assign 0 or null according to your database configuration.
You seem to be writing database operations
However, the $ tab_filed parameter is not required to be passed.
Because $ insert_arr should be an association array, and the association key should be the field name.
Upstairs positive solution, field name is not necessary
If the library is set to auto-increment, there is no need to insert it.
I know that the key is that you do not write the field name. isn't it all fields by default? you have to give it a value.
In mysql, null values can be inserted, but cannot be inserted through php.
I know that the key is that you do not write the field name. isn't it all fields by default? you have to give it a value.
In mysql, null values can be inserted, but cannot be inserted through php.
Just give NULL.
Thank you.
I know that the key is that you do not write the field name. isn't it all fields by default? you have to give it a value.
In mysql, null values can be inserted, but cannot be inserted through php.
Just give NULL.
$ SQL = "insert into test values ('u5', 'u5', NULL.
But I am talking about this situation. what value should $ a provide? $ A is an auto-incremental ID.
$;
$ SQL = "insert into test values ('u5', 'u5', $ )";
.
I know that the key is that you do not write the field name. isn't it all fields by default? you have to give it a value.
In mysql, null values can be inserted, but cannot be inserted through php.
Just give NULL.
$ SQL = "insert into test values ('u5', 'u5', NULL.
But I am talking about this situation. what value should $ a provide? $ A is an auto-incremental ID.
$;
$ SQL = "insert into test values ('u5', 'u5', $ )";
.
Why do I have to write a variable? is there any other purpose?