ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:qstr

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
reference:qstr [2015/07/19 06:59] – [Usage] mnewnhamv5:reference:connection:qstr [2018/07/16 19:38] – start functions lowercase peterdd
Line 2: Line 2:
 ~~NOTOC~~ ~~NOTOC~~
 <WRAP right box> <WRAP right box>
 +== See Also ==
 +[[v5:reference:connection:addq|addQ()]]\\
 == Syntax == == Syntax ==
   string qStr(   string qStr(
-         string $unquoted+         string $unquoted
 +         optional bool $dontFixQuotes=false
          )          )
 </WRAP> </WRAP>
 ==== Description ==== ==== Description ====
-The function ''qStr()'' takes an input string, and allows it to be appropriately quoted to a database-specific standard. If the string itself contains quotes, they are escaped in the correct way. The field can then be used, for example in an SQL statement.+The function ''qStr()'' takes an input string, and allows it to be
 + 
 +  Wrapped in single quotes.The value can then be used, for example in an SQL statement
 +  - Have quotes inside the string escaped in a way that is appropriate for the database. This is done wherever possible using PHP driver functions e.g. [[http://php.net/manual/en/mysqli.real-escape-string.php|MySQL real_escape_string]]. The second parameter, ''$dontFixQuotes'' stops any internal quoting happening, This parameter was mostly used in older versions of PHP when the now removed ''magic_quotes'' parameter was enabled, and the 2 methods were in conflict
  
 ------------------------------ ------------------------------
Line 17: Line 23:
 $SQL = "SELECT * FROM names WHERE name='$string'"; $SQL = "SELECT * FROM names WHERE name='$string'";
  
-$result = $db->Execute($SQL);+$result = $db->execute($SQL);
  
 /* /*
Line 31: Line 37:
 $SQL = "SELECT * FROM names WHERE name=$qString"; $SQL = "SELECT * FROM names WHERE name=$qString";
  
-$result = $db->Execute($SQL);+$result = $db->execute($SQL);
  
 /* /*
- * Execution Succeeds+ * Execution succeeds
  */  */
 </code> </code>
- 
  
v5/reference/connection/qstr.txt · Last modified: 2021/01/25 02:59 by mnewnham