Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

PDO: Database connections and abstraction

connection bound parameter

  • Please log in to reply
25 replies to this topic

#25 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 01 February 2012 - 05:04 AM

The only solution I found was to use PARAM_INT and use the number the enum value represent(I have to go and check in the database all the time). Using PARAM_STR didn't work in any way I could think of and just using INTs seems too messy. Saving it as TEXT or VARCHAR in the database would work but is out of the question, wasting that much space is ridiculous but saving it as INTs is just difficult. I want to save a row's order's type and referring to indices is only to beg for problem.
  • 0

#26 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 01 February 2012 - 03:59 PM

The reason why I question how you are using it, is that you can always bind it without a bound type:
$s = $db->prepare('SELECT countries FROM languages WHERE langid=?');
$s->execute(array('en')); //en happens to be enum 2

You could even substitute it with array($enumvalue) if 'en' is not static while still remaining safe with the "?" placeholder.

Hopefully that is a solution, I'd need to familiarise myself a little if not.

Alexander.
  • 1

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download