sprintf for db query strings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lars Eighner

    #1

    sprintf for db query strings


    I notice that many examples in the manual use sprintf in constructing
    database query strings. Is this just style, or are there some serious
    advantages to sprintf over concatenating the string, assuming in both
    cases that the variable parts of the string are properly sanitized?


    --
    Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
    Countdown: 566 days to go.
    Friends of Lizbeth: help replace failed a/c at Austin's no-kill shelter
    <https://secure.groundsp ring.org/dn/index.php?aid=1 2349>
  • ZeldorBlat

    #2
    Re: sprintf for db query strings

    On Jul 3, 8:06 pm, Lars Eighner <use...@larseig hner.comwrote:
    I notice that many examples in the manual use sprintf in constructing
    database query strings. Is this just style, or are there some serious
    advantages to sprintf over concatenating the string, assuming in both
    cases that the variable parts of the string are properly sanitized?
    >
    --
    Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
    Countdown: 566 days to go.
    Friends of Lizbeth: help replace failed a/c at Austin's no-kill shelter
    <https://secure.groundsp ring.org/dn/index.php?aid=1 2349>
    Just style. Personally I don't like the whole sprintf thing and
    prefer concatenation. Others prefer to put everything in double-
    quotes so variables are automatically inserted. It's all personal
    preference.

    Comment

    • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

      #3
      Re: sprintf for db query strings

      ZeldorBlat wrote:
      Just style. Personally I don't like the whole sprintf thing and
      prefer concatenation. Others prefer to put everything in double-
      quotes so variables are automatically inserted.
      Others use query bindings, so you don't even have to bother sanitizing the
      variable contents.

      Again, just coding style, and convenience for each particular case.

      --
      ----------------------------------
      Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

      Quien puede decir cuanto ama, pequeño amor siente.- Francesco Petrarca.

      Comment

      Working...