kristen Posted February 1, 2010 Share Posted February 1, 2010 Normally, when I run a query, it is in this format: $query = "SELECT * FROM table where id='$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo $query; which I like, because then I can add that "echo $query;" at the end and make sure all my variables are passing correctly. However, now I am forced to work within someone elses code, and I need to be sure that I am querying what I want to be querying, and the format is like this: return $this->_db->sql_select_one("table", '*', array('id'=>$id)); return array(); How can I print out what the query is that I am using? Thanks for any help, I am fairly new at this and I am driving myself crazy here!! Quote Link to comment Share on other sites More sharing options...
gizmola Posted February 1, 2010 Share Posted February 1, 2010 Depending on the library being used, there may not be any way of doing that, if for example they are using prepared statements. The first thing you need to do, is take a look at the database class and analyze it. See if it provides any sort of debugging switches you can turn on. You will need to understand how the library works. When you get errors, you may have to take a look at the mysql error returned and use that to reverse engineer the problem. Quote Link to comment Share on other sites More sharing options...
kristen Posted February 1, 2010 Author Share Posted February 1, 2010 Thanks for the quick reply. Re: analyzing errors - how about printing them out in full? All I get right now is "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0 LIMIT 1' at line 1" Quote Link to comment Share on other sites More sharing options...
gizmola Posted February 1, 2010 Share Posted February 1, 2010 Unfortunately that is all that's available from the mysql_error(). You can always go into the class and alter it to provide you a better form of debugging, or use it to derive a new class that has additions for your benefit. This is one of the benefits of oop. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.