02-27-2009, 03:23 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Some help
Hi!
I'm wondering what the error with the following code is:
php Code:
public function loadQuery ($query) { $this-> query_sql = $query; return $this; } public function exeQuery ($sql = NULL) { if($sql == NULL) { if(isset($this-> query_sql)) { $this-> query_result = mysql_query($this-> query_sql, $this-> conn); if($this-> query_result) { return $this; } return 'Query did not work'; } return 'Query sql not provided'; } else { $this-> loadQuery($sql)-> exeQuery(); } }
I've just done like this:
PHP Code:
$sql = "SELECT * FROM `test` WHERE `id` = '4'"; $fetch = $db->exeQuery($sql); echo $fetch;
This should actually give me an error: "Fatal blabla.. cannot convert object to string... blabla".. because it returns $this.. but it doesn't. It just displays blank.
Oh, and btw. It works if I do like:
PHP Code:
$sql = "SELECT * FROM `test` WHERE `id` = '4'"; $fetch = $db->loadQuery($sql)->exeQuery(); echo $fetch;
Then it gives me:
Code:
Catchable fatal error: Object of class DBmysql could not be converted to string in C:\wamp\www\Eldobado\index.php on line 9
which is correct.
But it doesn't seem like I can link them like I do, and skip the loadQuery.
Anyone see the problem?
__________________
|
|
|
|