Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    410
    Thanks
    6
    Thanked 3 Times in 3 Posts

    is there an index of old and new mysql/mysqli

    I have searched around, but totally lost. Google is not my friend at this moment in time.

    I am looking for an index of some kind that will give me basic examples like php.net does with then/now for each of the mysql commands and what they should be for mysqli. I understand that most of them you just swap the string and the command and remove the mysql_ but its the () part i am not clear on, as some of them you need the () and some you don't.

    Any links that users can suggest ?

  • #2
    Regular Coder
    Join Date
    Oct 2009
    Posts
    410
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Sorry I just realised, that yes PHP.net does have the conversion of mysql to mysqli, but I wish to use the shorthand method.

    mysql_fetch_assoc($results)

    becomes...

    $result->fetch_assoc()

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    That would be the object oriented method.
    I'm not sure what you are looking for. The overview here: http://www.php.net/manual/en/book.mysqli.php would break down the mysqli classes into what they can do, and it is listed in overview only as the object oriented functionality.
    Converting mysql to mysqli is not as simple as changing the functions. Even just sticking with the more traditional mysqli connection and mysqli result objects only, its still more complex than the mysql. Scope you now need to worry about (which is good, mysql should *never* have allowed global scope), and that doesn't even include the paradigm shift from procedural to object oriented.
    Function names are otherwise pretty much identical between the mysql library functions and mysqli methods. Some of them are identical in every way shape and form *except* the addition of the 'i' in it (eg: mysqli_fetch_assoc($resource) is near identical, except that $resource must be an object of type mysqli_result instead of an actual resource). Procedural to OO is typically done by appending the library name to the method, and supplying it with the first argument of the type. [icode]$result->fetch_assoc();[icode] would then be mysqli_fetch_assoc($result);. There are some exceptions, and some property only types such as mysqli::$current_field which requires an object call to property $result->current_field; or a completely different named function of mysqli_field_tell($result); for example. Some functionality has no replacement (such as mysql_result which I haven't found an exact copy of).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •