mckinneyhot
New Member
In wordpress I am querying the default table for custom rows and columns that I have manually added. I am globalizing the $wpdp (Wordpress database function) and it works for half of the code.For example the first part of the script is like so (only showing relevant parts of the code):\[code\] class Test { public function getP($param){ global $wpdb; $q = $wpdb->get_results("SELECT * FROM tbl WHERE " . $param['1']." = '" . $param['2'] . "'"); } }\[/code\]So that query works when running through $wpdb and I am able to print the results that get returned.However, further down I then need to run another query based on results, so instead of $wpdp->get_results i need to use $wpdp->query.Example (again, only the relavant):\[code\] global $wpdb; $stmt = $this->wpdb->query($q); if($param['type'] == 'x'){ $data = http://stackoverflow.com/questions/15869513/$stmt->fetchAll(); }else{$data = $stmt->fetch(); }return $data;\[/code\]That does not work, intead it seems to fall outside of the object and provide the following error:\[code\] Fatal error: Call to a member function query() on a non-object\[/code\]Any insight as to why the initial query works but than the second query results in an error, even though the database connection works and is inside of the object?