]> git.mxchange.org Git - friendica.git/commitdiff
Small corrections
authorMichael <heluecht@pirati.ca>
Tue, 25 Apr 2017 05:11:04 +0000 (05:11 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 25 Apr 2017 05:11:04 +0000 (05:11 +0000)
include/dba.php

index d4a05ff94873814ae8f8391df442943c9fb0b823..3383da86b574678c0f48000e23e7633bc59314c5 100644 (file)
@@ -443,8 +443,8 @@ class dba {
        }
 
        /**
-        * @brief Executes a prepared statement
-        *
+        * @brief Executes a prepared statement that returns data
+        * @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
         * @param string $sql SQL statement
         * @return object statement object
         */
@@ -529,6 +529,7 @@ class dba {
                                break;
                        case 'mysql':
                                // For the old "mysql" functions we cannot use prepared statements
+                               $offset = 0;
                                foreach ($args AS $param => $value) {
                                        if (is_int($args[$param]) OR is_float($args[$param])) {
                                                $replace = intval($args[$param]);
@@ -536,10 +537,11 @@ class dba {
                                                $replace = "'".dbesc($args[$param])."'";
                                        }
 
-                                       $pos = strpos($sql, '?');
+                                       $pos = strpos($sql, '?', $offset);
                                        if ($pos !== false) {
                                                $sql = substr_replace($sql, $replace, $pos, 1);
                                        }
+                                       $offset = $pos + strlen($replace);
                                }
 
                                $retval = mysql_query($sql, self::$dbo->db);
@@ -570,10 +572,10 @@ class dba {
        }
 
        /**
-        * @brief Executes a prepared statement
+        * @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
         *
         * @param string $sql SQL statement
-        * @return boolean Was the query successfull?
+        * @return boolean Was the query successfull? False is returned only if an error occurred
         */
        static public function e($sql) {
                $a = get_app();