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);   ?> 

modified wp-db class(wp-db.php): http://codepad.viper-7.com/coonyj


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -