summaryrefslogtreecommitdiff
path: root/includes/database.inc
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-08-26 08:27:09 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-08-26 08:27:09 +0000
commit39d776faa951a40eab75d035aa728fecd2803b58 (patch)
treed203a5539ccf1c42bb9671c2635df821d6bc2ad6 /includes/database.inc
parent7531f956aa542558d601a3d4f3039f4041793ec0 (diff)
downloadbrdo-39d776faa951a40eab75d035aa728fecd2803b58.tar.gz
brdo-39d776faa951a40eab75d035aa728fecd2803b58.tar.bz2
#157682 by bjaspan, chx and JirkaRybka: update.php for Drupal 6, to allow near flowless updates
Diffstat (limited to 'includes/database.inc')
-rw-r--r--includes/database.inc42
1 files changed, 42 insertions, 0 deletions
diff --git a/includes/database.inc b/includes/database.inc
index 053228310..ee60b80d9 100644
--- a/includes/database.inc
+++ b/includes/database.inc
@@ -445,5 +445,47 @@ function db_field_names($fields) {
}
/**
+ * Given a Schema API field type, return the correct %-placeholder to
+ * embed in a query to be passed to db_query along with a value from a
+ * column of the specified type.
+ *
+ * @param $type
+ * The Schema API type of a field.
+ * @return
+ * The placeholder string to embed in a query for that type.
+ */
+function _db_type_placeholder($type) {
+ switch ($type) {
+ case 'varchar':
+ case 'text':
+ case 'datetime':
+ return '\'%s\'';
+
+ case 'numeric':
+ // For 'numeric' values, we use '%s', not '\'%s\'' as with
+ // string types, because numeric values should not be enclosed
+ // in quotes in queries (though they can be, at least on mysql
+ // and pgsql). Numerics should only have [0-9.+-] and
+ // presumably no db's "escape string" function will mess with
+ // those characters.
+ return '%s';
+
+ case 'serial':
+ case 'int':
+ return '%d';
+
+ case 'float':
+ return '%f';
+
+ case 'blob':
+ return '%b';
+ }
+
+ // There is no safe value to return here, so return something that
+ // will cause the query to fail.
+ return 'unsupported type '. $type . 'for _db_type_placeholder';
+}
+
+/**
* @} End of "defgroup schemaapi".
*/