Database Interaction in Wordpress Flashcards
Q: What database management system does WordPress use?
A: MySQL or MariaDB.
Q: What is the default table prefix for WordPress tables?
A: wp_.
Q: How many default tables are there in a WordPress installation?
A: 12.
Q: What table stores post content and metadata?
A: wp_posts.
Q: What table stores user information?
A: wp_users.
Q: What global object is used for database interaction in WordPress?
A: $wpdb.
Q: How do you access the WordPress database prefix in code?
A: $wpdb->prefix.
Q: How do you retrieve a specific table name with $wpdb?
A: Use $wpdb->table_name (e.g., $wpdb->posts).
Q: What function should you use to prepare SQL queries safely?
A: $wpdb->prepare().
Q: Why is it important to prepare SQL queries?
A: To prevent SQL injection vulnerabilities.
Q: What method is used to run a SELECT query?
A: $wpdb->get_results().
Q: What method is used to fetch a single row from a query?
A: $wpdb->get_row().
Q: What method is used to fetch a single value from a query?
A: $wpdb->get_var().
Q: What method is used to insert data into a database?
A: $wpdb->insert().
Q: What method is used to update data in a database?
A: $wpdb->update().
Q: What method is used to delete data from a database?
A: $wpdb->delete().