Short answer, no. WPDB
is a class that’s been around for a while (back when WP used to support PHP 4), and lacks a lot of features PHP5 drivers offer, including parameter binding.
As you mentioned, wpdb::insert
is the closest you can get to your original code:
$wpdb->insert(
'importtest',
array(
'id' => $ID,
'area' => $area,
'country' => $country,
),
array(
'%d',
'%s',
'%s',
)
);
It uses wpdb::prepare
to escape the data, which works in a sprintf
-type fashion, supporting integers (%d
), floats (%f
) and strings (%s
):
$wpdb->prepare( "SELECT * FROM importtest WHERE area = %s", ' "foobar" ' );
// SELECT * FROM importtest WHERE area = " \"foobar\" "
Note that, like other driver prepare methods, there’s no need to quote the placeholder.
Related Posts:
- How do you properly prepare a %LIKE% SQL statement?
- $wpdb and MySQL Create Trigger
- wpdb->prepare function remove single quote for %s in SQL statment
- Alternative to mysql_real_escape_string
- Increment value (value = value+1) of $wpdb->update
- wpdb Custom Meta Data with 2 conditions
- wpdb prepare syntax
- SQL query not working in alphabetical post title/content search
- MySQL LIKE not working
- Proper way to work with wpdb to get user’s firstname
- How to check for empty and not a failure
- Database: Custom table: sprintf value for DateTime column
- Converting mysql to $wpdb
- WP_USE_EXT_MYSQL
- wpdb insert and boolean fields
- Join new table with SQL query
- writing inner join in wpdb
- How to split the a table in database?
- MySQL Rank & $wpdb
- When WordPress Default table, Echo Success. When Plugin Table, Echo Blank
- How do I join a $wpdb query with user meta using default value if not exist?
- How to translate this mySQL query to $wpdb query
- $wpdb select all meta for each post
- $wpdb to insert html form information
- Proper usage of $wpdb->update()?
- WordPress(wpdb class) and mysql stored procedures
- Can’t run database query
- Active DB queries in WordPress?
- How to stop $wpdb from prepending database name
- WordPress $wpdb get posts from category and sort by custom meta
- How to get INSERT errors from $wpdb?
- Getting Error Trying to Create Table
- How to set MYSQLI_OPT_INT_AND_FLOAT_NATIVE option
- Understanding custom php that reads from WP MYSQL
- How to insert dash (-) into database using wpdb and new_to_publish hook?
- $wpdb->get_var multiple queries in one database check
- List users with the most posts in the last 30 days
- Insert two row in wordpress database
- WordPress $wpdb no result
- PHP variables in mysql query
- MySQL ‘duplicate entry’ error
- User set date and time from frontend doesn’t get stored into database
- Wpdb query with dynamic table name
- get posts whether meta_key exists or not
- when using $wpdb sudden connection rejection without changing anything. Access denied, with errors from repair tool
- How to search usermeta table
- How to add virtual column in wpdb get_result statement
- wpdb insert into point column in db
- WPDB delivers wrong results from complex queries
- $wpdb post type and term query only works when there are no dashes or spaces in the term slug and title
- CONCAT_WS in custom sql query
- Geographical proximity query using post_meta
- MySQL Select within WP Page template
- Saving custom term value to the database in new table
- why is $wpdb->update() causing a DB error from within wp_set_password()
- $wpdb->get_var returns 0
- Initialization of table in database using ‘CREATE … IF NOT EXISTS’
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
- When to use SELECT … FOR UPDATE?
- #1045 – Access denied for user ‘root’@’localhost’ (using password: YES)
- Can’t open the mysql.plugin table. Please run mysql_upgrade to create it
- Convert MySQL to SQlite [closed]
- MySql: is it possible to ‘SUM IF’ or to ‘COUNT IF’?
- MySQL: What’s the difference between float and double?
- How can I search (case-insensitive) in a column using LIKE wildcard?
- SQL – IF EXISTS UPDATE ELSE INSERT INTO
- How to unblock with mysqladmin flush hosts
- Node.js MySQL – Error: connect ECONNREFUSED
- MySQL – UPDATE query with LIMIT
- MySQL said: Documentation #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)
- Can i use php sql functions instead of $wpdb?
- how to refresh wordpress permalink settings? (without admin panel)
- Ordering posts by day (not time) AND meta value
- Problems with DBDelta with FOREIGN key?
- Custom query to get post names beginning with a digit
- How to add 2 hours to the wordpress time formed with current_time(“mysql”, false)?
- wpdb_prepare with multiple or condition
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- I want to select the from values from database in WordPress? [closed]
- #1115 – Unknown character set: ‘utf8mb4’
- Slow wp-admin due to “SELECT DISTINCT post_mime_type FROM wp_posts WHERE post_type = ‘attachment'”
- wpdb COALESCE won’t work
- database optimization and server errors
- Setting up WordPress Locally on WAMP for a new site (with one already)
- Calling mysql_query() on another database, assumes WordPress using that database
- querying user bookmarks from a large number of bookmarks
- Get post featured image id with $wpdb
- How to fix the amount of comments displayed for each post?
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- What is the correct way to search 3 custom fields only in WordPress?
- SQL query to change custom field in WordPress database
- MySQL Actibity without any active visitors via Google Analytics
- Why is local wordpress install calling live site executions?
- Display MySQL as part of a Page
- WP Meta Query – mixed AND / OR query doesn’t work
- $wpdb how can i save my postmeta table before querying it
- Internal error (500) on local & Fatal error on live when trying to access post type edit screen
- Query sql for truncate post_content in wp_posts table
- Foreach only outputs if id is 0