FUDforum - خوراک RDF
http://fudforum.org/forum/index.php
determine a mysqli_result object
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181268&th=123038#msg_181268
The problem I ran into is this.
Previously I could check the mysql_query if it return a resource by using:
is_resource($resource)
and could parse the resource using mysql_fetch_assoc or similar
and if it was an insert, update, etc.. it would not return a resource
and I would just return a true and carry on.
Now with mysqli it return a mysql_result object.
How do I check for this so I know whether to parse or return
Thanks
Here is a nutshell of what was using for mysql
// Already connected to mysqli
public function query($query){
$resource = $this->connection->query($query);
Scotty]]>Scott Johnson2013-04-27T23:11:40-00:00Re: determine a mysqli_result object
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181269&th=123038#msg_181269
> I have a class that I am converting from mysql to mysqli in PHP 5.2.x
>
> The problem I ran into is this.
>
> Previously I could check the mysql_query if it return a resource by using:
>
> is_resource($resource)
>
> and could parse the resource using mysql_fetch_assoc or similar
>
> and if it was an insert, update, etc.. it would not return a resource
> and I would just return a true and carry on.
>
> Now with mysqli it return a mysql_result object.
>
> How do I check for this so I know whether to parse or return
>
> Thanks
>
> Here is a nutshell of what was using for mysql
>
> // Already connected to mysqli
>
> public function query($query){
> $resource = $this->connection->query($query);
>
> if($resource) {
>
> if(is_resource($resource)) { // parse
>
> $data = array();
>
> $idx = 0;
>
> while($result = $this->connection->fetch_assoc()) {
>
> $data[$idx] = $result;
> // Object assembly
>
> }
> } else { // return
>
> // update, insert, etc..
> return true;
>
> }
> } else {
> // error
> }
> }
>
> Scotty
Crap figured it out. Was binging for the wrong answer.