Req #48290 [Bgs]: auto escape for variables in double quoted sql string

From: Date: Mon, 22 Mar 2010 18:30:49 +0000
Subject: Req #48290 [Bgs]: auto escape for variables in double quoted sql string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148854@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=48290&edit=1

 ID:               48290
 User updated by:  kexianbin at diyism dot com
 Reported by:      kexianbin at diyism dot com
 Summary:          auto escape for variables in double quoted sql string
 Status:           Bogus
 Type:             Feature/Change Request
 Package:          *General Issues
 Operating System: Irrelevant
 PHP Version:      5.3.3

 New Comment:

function safe_query($scope, $sql)
         {extract($scope);
          $sql=strtr($sql, array('"'=>'\"',
'\\'=>'\\\\'));
          $sql=eval('return "'.preg_replace(array('/\{#(.*?)\}/'),
array('".addslashes($\1)."'), $sql).'";');
          mysql_query($sql);
         }
safe_query(get_defined_vars(),
           "insert into z_test (name, value) values ('{$name}',
'{#value}')"
          );


Previous Comments:
------------------------------------------------------------------------
[2010-03-22 10:39:42] johannes@php.net

As others told you: This feature won't be implemented.

------------------------------------------------------------------------
[2010-03-22 10:30:18] kexianbin at diyism dot com

,

------------------------------------------------------------------------
[2010-03-22 10:30:07] kexianbin at diyism dot com

,

------------------------------------------------------------------------
[2010-03-22 10:29:52] kexianbin at diyism dot com

,

------------------------------------------------------------------------
[2009-12-16 10:41:10] derick@php.net

.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=48290


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=48290&edit=1


Thread (39 messages)

« previous php.bugs (#148854) next »