Is my choice of mysqli_real_connect the correct one

Discussion in 'PHP' started by pipes, Jun 14, 2010.

  1. #1
    *Im trying to learn the very basics*

    Ok ive figured that its best for me to use MySQLi instead of MySQL, right i see that mysqli_connect is within the deprecated and alias list so i shouldn't be using that either?

    *Looking at the manual*

    I see mysqli_real_connect and i think this is my correct choice? It mentions the bit about needing mysqli_init()

    Am i choosing the right function for when i want to connect to the database? The mysqli_real_connect one.
     
    pipes, Jun 14, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Its not deprecated... well.... not really. (it will be as its an alias but for arguments sake.....)

    See here; http://uk.php.net/manual/en/mysqli.connect.php

    Its a constructor. When you create an object its automatically invoked unless its inherited.

    mysqli_real_connect - i dont know where you got that advice from but you should ignore it asap. Stick to the php manual and
    you cant go wrong.

    EDIT.

    Sorry, I see you say you are learning the basics. have you programmed before in any language?

    procedural and objects are two completely different beasts. The formar is easier, but latter more efficient once you use it correctly. Is there any reason you say mysqli is best for you to use?
     
    Last edited: Jun 14, 2010
    lukeg32, Jun 14, 2010 IP
  3. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #3
    Hi Luke

    If it will become deprecated though, wont it be better to not use mysqli_connect if im just starting with php.

    mysqli_real_connect is purely me believing thats the one i think i should use, while looking through the manual.

    Ive never programmed before in any language, ive been reading recently about procedural and OOP, and realise that its a good idea to learn OOP, but i realise that i need to understand procedural even if i want to eventually go more in the direction of OOP.

    Im reading how the MySQLi extension has a number of added benefits, and the php manual suggesting "If you are using MySQL versions 4.1.3 or later it is strongly recommended that you use this extension."

    Regarding mysqli_connect being an alias and how it will be depracated eventually, if im understanding that correctly, the alias thing leading to deprecation im not 100% clear on, if you can explain more i will be glad of it.

    Because im just starting to learn php, i dont want to start using things that i maybe shouldn't be.
     
    pipes, Jun 14, 2010 IP