PHP SQL query for local DB other than $wpdb
-
Hi Peter,
I love this plugin and Code Manager for being able to easily show dynamic content on my pages.
However, I need to utilize one of my existing database table that contains dynamic content for my wp pages across different wp installations.
The current solution I am working on in to ‘replicate’ this database table in a local database (not the wordpress db) and add the wordpress db user to this local db. (I did not want to use remote db connection for security reasons.)
I know that $wpdb have “esc_like()” and “prepare()” functions for safe execution of SQL query and am currently using it.
Does $wpdadb have the same or similar functions for safe execution of SQL query?Here is a sample snippet of my current sql query using $wpdb that needs converting to $wpdadb:
$param1 = $wpdb->esc_like($wpda_shortcode_args['param1']); $param2 = '%0' . $wpdb->esc_like($param2) . '0%'; $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM my_table WHERE my_col2 LIKE %s AND my_col3 LIKE %s ORDER BY my_col2 ASC", $param1, $param2 ) );
- The topic ‘PHP SQL query for local DB other than $wpdb’ is closed to new replies.