One of my components requires info from a database that’s in the same schema, but a different table. I’m still new to working through the practice of backend throughput, but am wondering how best to log into the database without putting plaintext passwords into Sage theme functions.
Ideally a function like the following wouldn’t include the actual credentials (also my code probably is shotty…)
As an aside, when I run the above I get the error, ‘Call to undefined function App\Controllers\mysql_connect()’ but I suspect that’s probably one of my configuration errors. mysqli is undefined too if I switch it to that.
Warning: Methods in the wpdb() class should not be called directly. Use the global $wpdb object instead!
WordPress provides a global object variable, $wpdb , which is an instantiation of the wpdb class defined in /wp-includes/wp-db.php. By default, $wpdb is instantiated to talk to the WordPress database. To access $wpdb in your WordPress PHP code, declare $wpdb as a global variable using the global keyword , or use the superglobal $GLOBALS […]
use Sober\Controller\Controller;
class App extends Controller
{
public function tidestations() {
global $wpdb;
$wpdb = get_results("SELECT exampletable FROM exampledb");
}
}
In blade:
{!! $tidestations !!}
Result:
Result: Uncaught Error: Call to undefined function App\Controllers\get_results()
Thanks in advance for your help on this. Let me know if there are any other areas or logs to output for review.