Wordpress $wpdb->options
Where does $wpdb->options
com开发者_JS百科e from?
I can't see $wpdb-options()
function or $this->options
so how is this achieved?
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()
and get_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 class wpdb
).
It's value is the name of the options table in the database, usually wp_options
.
$wpdb->options
is defined through wp_set_wpdb_vars()
in wp-includes/load.php
.
This line sets the table names via a call to the set_prefix function:
$prefix = $wpdb->set_prefix( $table_prefix );
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.
精彩评论