php - Is there a way to use the WPDB class into a non-wordpress project? -
because wordpress wpdb class easy use, want try using non-wordpress project. tried copy wp-db.php
working directory , tried following script on separate file
<?php require_once("wp-db.php"); $mydb = new wpdb('myuser','mypassword','mydatabase','myhost'); $rows = $mydb->get_results("select column1 table1"); foreach ($rows $obj) echo $obj->column1."<br/>"; endforeach; ?>
but couldn't make display data.
is there way use wpdb class on non-wordpress project?
test code(test.php):
<?php require_once("wp-db.php"); $mydb = new wpdb('root','','mysql','localhost'); $row = $mydb->get_results("select * user limit 1"); var_dump($row); ?>
Comments
Post a Comment