SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Can I do it?

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I do it?

    Just getting my feet wet with PHP and MYSQL, so I apologize if this seems like a simple question.

    I need to add a parameter to a search function.

    Currently I have

    Code:
    AND (this_field >= ? OR second_field >= ?)
    I would like to add a field like so

    Code:
    AND (this_field >= ? OR second_field >= ? OR third_field >= ?)
    Will that work? Any advise is appreciated.

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,066
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    So long as you also bind the third parameter or include it in the array when calling execute() you should be fine.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure what you mean by bind, but currently it is all wrapped up in a class. I then call the value if that makes sense?

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,066
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rjfec View Post
    I am not sure what you mean by bind, but currently it is all wrapped up in a class. I then call the value if that makes sense?
    Yes, that makes some sense, the reason I referred to bind was due to the ? placeholders shown in your query.

    Here are a few of the possibilities on when those are used (they provide examples of what I was referring to)
    http://www.php.net/manual/en/pdostatement.bindvalue.php
    http://www.php.net/manual/en/pdostatement.bindparam.php
    http://www.php.net/manual/en/pdostatement.execute.php
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you


Bookmarks

Posting Permissions

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