Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
310
Merge Requests
310
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
86e09fa4
Commit
86e09fa4
authored
May 30, 2007
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#147692
by hswong3i: gives SQL backends more control over db_query().
parent
682c4cc2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
36 deletions
+72
-36
includes/database.inc
includes/database.inc
+0
-36
includes/database.mysql-common.inc
includes/database.mysql-common.inc
+36
-0
includes/database.pgsql.inc
includes/database.pgsql.inc
+36
-0
No files found.
includes/database.inc
View file @
86e09fa4
...
...
@@ -185,42 +185,6 @@ function _db_query_callback($match, $init = FALSE) {
*/
define
(
'DB_QUERY_REGEXP'
,
'/(%d|%s|%%|%f|%b)/'
);
/**
* Runs a basic query in the active database.
*
* User-supplied arguments to the query should be passed in as separate
* parameters so that they can be properly escaped to avoid SQL injection
* attacks.
*
* @param $query
* A string containing an SQL query.
* @param ...
* A variable number of arguments which are substituted into the query
* using printf() syntax. Instead of a variable number of query arguments,
* you may also pass a single array containing the query arguments.
*
* Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
* in '') and %%.
*
* NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
* and TRUE values to decimal 1.
*
* @return
* A database query result resource, or FALSE if the query was not
* executed correctly.
*/
function
db_query
(
$query
)
{
$args
=
func_get_args
();
array_shift
(
$args
);
$query
=
db_prefix_tables
(
$query
);
if
(
isset
(
$args
[
0
])
and
is_array
(
$args
[
0
]))
{
// 'All arguments in one array' syntax
$args
=
$args
[
0
];
}
_db_query_callback
(
$args
,
TRUE
);
$query
=
preg_replace_callback
(
DB_QUERY_REGEXP
,
'_db_query_callback'
,
$query
);
return
_db_query
(
$query
);
}
/**
* Helper function for db_rewrite_sql.
*
...
...
includes/database.mysql-common.inc
View file @
86e09fa4
...
...
@@ -12,6 +12,42 @@
* @{
*/
/**
* Runs a basic query in the active database.
*
* User-supplied arguments to the query should be passed in as separate
* parameters so that they can be properly escaped to avoid SQL injection
* attacks.
*
* @param $query
* A string containing an SQL query.
* @param ...
* A variable number of arguments which are substituted into the query
* using printf() syntax. Instead of a variable number of query arguments,
* you may also pass a single array containing the query arguments.
*
* Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
* in '') and %%.
*
* NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
* and TRUE values to decimal 1.
*
* @return
* A database query result resource, or FALSE if the query was not
* executed correctly.
*/
function
db_query
(
$query
)
{
$args
=
func_get_args
();
array_shift
(
$args
);
$query
=
db_prefix_tables
(
$query
);
if
(
isset
(
$args
[
0
])
and
is_array
(
$args
[
0
]))
{
// 'All arguments in one array' syntax
$args
=
$args
[
0
];
}
_db_query_callback
(
$args
,
TRUE
);
$query
=
preg_replace_callback
(
DB_QUERY_REGEXP
,
'_db_query_callback'
,
$query
);
return
_db_query
(
$query
);
}
/**
* Generate SQL to create a new table from a Drupal schema definition.
*
...
...
includes/database.pgsql.inc
View file @
86e09fa4
...
...
@@ -111,6 +111,42 @@ function db_connect($url) {
return
$connection
;
}
/**
* Runs a basic query in the active database.
*
* User-supplied arguments to the query should be passed in as separate
* parameters so that they can be properly escaped to avoid SQL injection
* attacks.
*
* @param $query
* A string containing an SQL query.
* @param ...
* A variable number of arguments which are substituted into the query
* using printf() syntax. Instead of a variable number of query arguments,
* you may also pass a single array containing the query arguments.
*
* Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
* in '') and %%.
*
* NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
* and TRUE values to decimal 1.
*
* @return
* A database query result resource, or FALSE if the query was not
* executed correctly.
*/
function
db_query
(
$query
)
{
$args
=
func_get_args
();
array_shift
(
$args
);
$query
=
db_prefix_tables
(
$query
);
if
(
isset
(
$args
[
0
])
and
is_array
(
$args
[
0
]))
{
// 'All arguments in one array' syntax
$args
=
$args
[
0
];
}
_db_query_callback
(
$args
,
TRUE
);
$query
=
preg_replace_callback
(
DB_QUERY_REGEXP
,
'_db_query_callback'
,
$query
);
return
_db_query
(
$query
);
}
/**
* Helper function for db_query().
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment