Welcome Guest, Not a member yet? Register   Sign In
Including $wpdb into CI
#1

[eluser]nextexile[/eluser]
I'm trying to include the $wpdb class from a wordpress installation in a subfolder of CI. Actualy loading goes well, but when I initialize the wpdb, it seems to be unable to pull any data.

I have a blog model and in the constructor I load:

Code:
require_once( $_SERVER['DOCUMENT_ROOT'].'wp/wp-config.php' );
require_once( $_SERVER['DOCUMENT_ROOT'].'wp/wp-includes/wp-db.php' );

Then, in a method, I initialize the object.

Code:
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
var_dump($wpdb);

What I get is this, you'll notice that there are many NULL values but the object does get created and connects to the database. At least that's the way it seems.

Code:
object(wpdb)#24 (48) { ["show_errors"]=> bool(false) ["suppress_errors"]=> bool(false) ["last_error"]=> string(0) "" ["num_queries"]=> int(0) ["num_rows"]=> int(0) ["rows_affected"]=> int(0) ["insert_id"]=> int(0) ["last_query"]=> NULL ["last_result"]=> NULL ["col_info"]=> NULL ["queries"]=> NULL ["prefix"]=> string(0) "" ["ready"]=> bool(true) ["blogid"]=> int(0) ["siteid"]=> int(0) ["tables"]=> array(9) { [0]=> string(5) "posts" [1]=> string(8) "comments" [2]=> string(5) "links" [3]=> string(7) "options" [4]=> string(8) "postmeta" [5]=> string(5) "terms" [6]=> string(13) "term_taxonomy" [7]=> string(18) "term_relationships" [8]=> string(11) "commentmeta" } ["old_tables"]=> array(3) { [0]=> string(10) "categories" [1]=> string(8) "post2cat" [2]=> string(8) "link2cat" } ["global_tables"]=> array(2) { [0]=> string(5) "users" [1]=> string(8) "usermeta" } ["ms_global_tables"]=> array(7) { [0]=> string(5) "blogs" [1]=> string(7) "signups" [2]=> string(4) "site" [3]=> string(8) "sitemeta" [4]=> string(14) "sitecategories" [5]=> string(16) "registration_log" [6]=> string(13) "blog_versions" } ["comments"]=> NULL ["commentmeta"]=> NULL ["links"]=> NULL ["options"]=> NULL ["postmeta"]=> NULL ["posts"]=> NULL ["terms"]=> NULL ["term_relationships"]=> NULL ["term_taxonomy"]=> NULL ["usermeta"]=> NULL ["users"]=> NULL ["blogs"]=> NULL ["blog_versions"]=> NULL ["registration_log"]=> NULL ["signups"]=> NULL ["site"]=> NULL ["sitecategories"]=> NULL ["sitemeta"]=> NULL ["field_types"]=> array(0) { } ["charset"]=> string(4) "utf8" ["collate"]=> string(0) "" ["real_escape"]=> bool(true) ["dbuser"]=> string(2) "wp" ["func_call"]=> NULL ["is_mysql"]=> bool(true) ["dbpassword"]=> string(13) "redacted" ["dbname"]=> string(2) "wp" ["dbhost"]=> string(9) "localhost" ["dbh"]=> resource(54) of type (mysql link) }

So, my thinking is, does wpdb require any additional files to be loaded in order to function properly? Do I have some obvious errors? How do I actually test wpdb's connection? It's not showing any signs of errors but I'm also unable to get any data, what gives?




Theme © iAndrew 2016 - Forum software by © MyBB