1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Which query approach to use?

Discussion in 'MySQL' started by MikeHayes, Nov 7, 2010.

  1. #1
    Question;

    When should I use $sql = "query etc"; and when should I use $result = mysqli_query($link, "query etc");?

    Are there other better ways to do it or worse ways to avoid?

    Thanks.
     
    MikeHayes, Nov 7, 2010 IP
  2. imocoder

    imocoder Member

    Messages:
    45
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    You use:
    $sql = "query etc";
    PHP:
    when you want to do some extra operation with your $sql variable.

    Anyway you can use any of these without problem.
     
    imocoder, Nov 15, 2010 IP
  3. teamaguilar

    teamaguilar Peon

    Messages:
    197
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    mysqli_query() function performs a query against the database represented by the link parameter.
     
    teamaguilar, Nov 23, 2010 IP
  4. MattCA

    MattCA Peon

    Messages:
    14
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It really doesn't matter which one you use, as both do the same work. In first case you just assign query string to variable and then use mysqli_query to execute, while in the latter you just execute given string without any variable. In theory, second way should be more efficient.
     
    MattCA, Nov 24, 2010 IP