Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-13-2008, 11:46 AM
Junior Member
 
Join Date: Apr 2008
Posts: 1
Default wrapper class

Hi,

ive got a problem with my mysql-wrapper class to include the zf db component to an existing project.

the old mysql class looks like this:

PHP Code:
class mysql {
    function 
fetch_array ($strResult){
        if (!
$this->bError) {
            return 
mysqli_fetch_array($strResult);
        } else {
            return 
false;
        }
    }
...

and this is the wrapper class for the old mysql class:
PHP Code:
class mysql {
    function 
query ($strQuery){
        global 
$db;
        return 
$db->query($strQuery);
    }

    function 
fetch_array ($strResult){
        
$i=0;
        foreach((array)
$strResult->fetch() as $k => $v){
            
$result[$i] = $v;
            
$result[$k] = $v;
        ++
$i;}

        return 
...

Yes, global $db is bad code, but doesnt matter right now.

The problem is, when i use 2 times "query" in while:

PHP Code:
$res=$mysql->query("select * from test;");
while(
$row $mysql->fetch_array($res)){
    
$res2=$mysql->query("select * from test2;");

this ends with an loop!

when i remove the second "query", it works!
But with "query" in the while, it doesnt work.

Whats the problem? i cant find it :/.

Thanks!

kevin

Greetings from germany && sorry for bad english
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:38 AM.