Inserts a row into the table.
Examples:
$wpdb->insert(
'table',
array(
'column1' => 'foo',
'column2' => 'bar',
)
);
$wpdb->insert(
'table',
array(
'column1' => 'foo',
'column2' => 1337,
),
array(
'%s',
'%d',
)
); $tablestringrequired
$dataarrayrequired
$data columns and $data values should be "raw" (neither should be SQL escaped).$formatstring[]|stringoptional
$data.$data.'%d', '%f', '%s' (integer, float, string).$data will be treated as strings unless otherwise specified in wpdb::$field_types. Default:null
public function insert( $table, $data, $format = null ) {
return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' );
}
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wpdb/insert