is this news to anybody else? (Mysqli OOP is same as procedural)

Discussion in 'Programming/Scripts' started by rodobrist, Mar 9, 2011.

  1. rodobrist

    rodobrist New Member

    Hi all,
    I was experimenting with the differences between using a mysqli resource ie:

    "procedural":
    PHP:
    $handle=mysqli_connect('localhost','usr','pass','DBNAME');
    $result=mysqli_query($handle,'SELECT * FROM tablename);
    "OOP":
    PHP:
    $dbc= new MySQLi('localhost','usr','pass','DBNAME');
    $result=$dbc->query($handle,'SELECT * FROM tablename);
    nothing fancy here, but what really surprised me was this:

    "procedural":
    PHP:
    $handle=mysqli_connect('localhost','usr','pass','DBNAME');
    $result=$handle->query($handle,'SELECT * FROM tablename);
    "OOP":
    PHP:
    $dbc= new MySQLi('localhost','usr','pass','DBNAME');
    $result=$mysqli_query($dbc,'SELECT * FROM tablename);
    hopefully you can all see what i am getting at. Maybe you all knew this but I thought there was a distinct difference between a handle/resource (which i think are the same in php) and an Object and I'm pretty sure i read that mysqli_connect returns a resource.

    I double checked the manual, and mysql_connect returns a resource, whereas mysqli_connect returns an object.

    thought this was worth sharing
     
    Last edited: Mar 9, 2011

Share This Page