- Timestamp:
- 07/07/09 08:01:06 (1 year ago)
- Files:
-
- fDatabase.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fDatabase.php
r603 r630 Hide Line Numbers 47 47 * @link http://flourishlib.com/fDatabase 48 48 * 49 * @version 1.0.0b12 49 * @version 1.0.0b13 50 * @changes 1.0.0b13 Updated ::escape() to accept arrays of values for insertion into full SQL strings [wb, 2009-07-06] 50 51 * @changes 1.0.0b12 Updates to ::unescape() to improve performance [wb, 2009-06-15] 51 52 * @changes 1.0.0b11 Changed replacement values in preg_replace() calls to be properly escaped [wb, 2009-06-11] … … 799 800 * - `%p` for a timestamp 800 801 * 802 * Depending on what `$sql_or_type` and `$value` are, the output will be 803 * slightly different. If `$sql_or_type` is a data type or a single 804 * placeholder and `$value` is: 805 * 806 * - a scalar value - an escaped SQL string is returned 807 * - an array - an array of escaped SQL strings is returned 808 * 809 * If `$sql_or_type` is a SQL string and `$value` is: 810 * 811 * - a scalar value - the escaped value is inserted into the SQL string 812 * - an array - the escaped values are inserted into the SQL string separated by commas 813 * 801 814 * @param string $sql_or_type This can either be the data type to escape or an SQL string with a data type placeholder - see method description 802 * @param mixed $value The value to escape - you should pass a single value or an array of values if a data type is specified, or a value for each placeholder815 * @param mixed $value The value to escape - both single values and arrays of values are supported, see method description for details 803 816 * @param mixed ... 804 817 * @return mixed The escaped value/SQL or an array of the escaped values … … 904 917 switch ($piece) { 905 918 case '%l': 906 $ sql .= $this->escapeBlob($value);919 $callback = $this->escapeBlob; 907 920 break; 908 921 case '%b': 909 $ sql .= $this->escapeBoolean($value);922 $callback = $this->escapeBoolean; 910 923 break; 911 924 case '%d': 912 $ sql .= $this->escapeDate($value);925 $callback = $this->escapeDate; 913 926 break; 914 927 case '%f': 915 $ sql .= $this->escapeFloat($value);928 $callback = $this->escapeFloat; 916 929 break; 917 930 case '%i': 918 $ sql .= $this->escapeInteger($value);931 $callback = $this->escapeInteger; 919 932 break; 920 933 case '%s': 921 $ sql .= $this->escapeString($value);934 $callback = $this->escapeString; 922 935 break; 923 936 case '%t': 924 $ sql .= $this->escapeTime($value);937 $callback = $this->escapeTime; 925 938 break; 926 939 case '%p': 927 $ sql .= $this->escapeTimestamp($value);940 $callback = $this->escapeTimestamp; 928 941 break; 929 942 default: 930 943 $sql .= $piece; 931 944 continue 2; 932 } 945 } 946 947 if (is_array($value)) { 948 $sql .= join(', ', array_map($callback, $value)); 949 } else { 950 $sql .= call_user_func($callback, $value); 951 } 952 933 953 if (sizeof($values)) { 934 954 $value = array_shift($values);
