fetch_array oop

Discussion in 'PHP' started by goppss, Sep 17, 2012.

  1. #1
    Hi guys,

    I'm new to php object oriented programming and therefore seeking some help. The first set of code runs a fetch array which when run in conjunction with the second set of code in an index.php page. I'm unable to access the variables $tag, $date etc in this index.php page though var_dump is showing all the content in an array. Any help would be appreciate in solving this issue.


     
    Last edited: Sep 17, 2012
    goppss, Sep 17, 2012 IP
  2. awood969

    awood969 Member

    Messages:
    186
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    40
    #2
    Your row function takes no parameters so $this->results->fetch... so its seeing $this as null.

    It seems like an OTT set of functions in my opinion, PHP wraps everything up nicely.

    You should do the following using PHP's own functions (dump your include file).

    1) Connect to the database using mysqli();
    2) Run your query using mysqli->query(); Capture the result in a new variable (e.g. $result = $myconn->query();)
    3) Use fetch row rather than array, it means you must match column numbers rather than column names but its much much quicker to process (e.g. $details = $result->fetchRow();)
    4) Use $details to assign as needed (e.g. $tag = $details[0]; $metakey = $details[1];)

    Hope this helps. It should be a lot simpler than your current implementation.

    Thanks
    Andrew
     
    awood969, Sep 19, 2012 IP