Where does $wpdb->options
come from?
I can’t see $wpdb-options()
function or $this->options
so how is this achieved?
Where does $wpdb->options
come from?
I can’t see $wpdb-options()
function or $this->options
so how is this achieved?
You must be logged in to post a comment.
Okay, here is a complete clarification of the confusion I can see here.
$wpdb
is an object for querying the database. The$wpdb->options
property is merely the name of the options table in the database. It does not store nor contain the contents of that table.WordPress options (or settings) are stored, updated and read using the functions
add_option()
,update_option()
andget_option()
respectively.You can also get all options using
get_alloptions()
.The reason you should use $wpdb properties to reference tables in your SQL queries is that the table prefix is user defined, and you cannot assume it will always be called ‘wp_tablename’.
$wpdb->options
is a property of the object$wpdb
(which is an instance of the classwpdb
).It’s value is the name of the options table in the database, usually
wp_options
.$wpdb->options
is defined throughwp_set_wpdb_vars()
inwp-includes/load.php
.This line sets the table names via a call to the set_prefix function:
Hope this helps!
“wpdb” is class to interact with database. Its in “wp-db.php”. since i don’t know what exactly you are asking about this link might be helpful for you.
I think people are struggling to understand your question. Maybe provide a bit more detail or context.
If you are asking where the options originally came from, then the answer is that they are set during setup and in the WP Admin pages. They are then stored in the wp_options table in your database, and retrieved into the $wpdb->options variable that is a member of the $wpdb object when WordPress loads.