[Fusionforge-commits] r14212 - trunk/src/common/include
Olivier Berger
olberger at fusionforge.org
Wed Aug 24 13:30:38 CEST 2011
Author: olberger
Date: 2011-08-24 13:30:38 +0200 (Wed, 24 Aug 2011)
New Revision: 14212
Modified:
trunk/src/common/include/database-pgsql.php
Log:
Add docs
Modified: trunk/src/common/include/database-pgsql.php
===================================================================
--- trunk/src/common/include/database-pgsql.php 2011-08-24 11:30:36 UTC (rev 14211)
+++ trunk/src/common/include/database-pgsql.php 2011-08-24 11:30:38 UTC (rev 14212)
@@ -526,7 +526,18 @@
return $res ;
}
+/**
+ * db_construct_qpa() - Constructs a query+params array to be used by db_query_qpa()
+ * Can be called several times in a row to extend the query, until db_query_qpa will be finally invoked.
+ *
+ * @param array $old_qpa array(SQL query, array(parameters...), oldmax) of previous calls
+ * @param string $new_sql SQL instructions added to the query
+ * @param array $new_params new params matching the new query instructions
+ * @return array array(SQL query, array(parameters...), newmax)
+ */
function db_construct_qpa ($old_qpa = false, $new_sql = '', $new_params = array ()) {
+
+ // can be invoked for the first time, starting with no previous query
if (!is_array($old_qpa) || count ($old_qpa) < 3) {
$old_qpa = array ('', array(), 0) ;
}
@@ -538,6 +549,7 @@
$params = $old_params ;
$max = $old_max ;
+ // renumber the $n params substitution placeholders to be able to concatenate
foreach ($new_params as $index => $value) {
$i = count ($new_params) - $index ;
$new_sql = preg_replace ('/\\$'.$i.'(?!\d)/', '$_'.($i + $old_max), $new_sql) ;
More information about the Fusionforge-commits
mailing list