Пример #1
0
 function _query($sql, $inputarr = false)
 {
     if (!$this->_bindInputArray) {
         // We don't have native support for parameterized queries, so let's emulate it at the parent
         return ADODB_postgres64::_query($sql, $inputarr);
     }
     $this->_pnum = 0;
     $this->_errorMsg = false;
     // -- added Cristiano da Cunha Duarte
     if ($inputarr) {
         $sqlarr = explode('?', trim($sql));
         $sql = '';
         $i = 1;
         $last = sizeof($sqlarr) - 1;
         foreach ($sqlarr as $v) {
             if ($last < $i) {
                 $sql .= $v;
             } else {
                 $sql .= $v . ' $' . $i;
             }
             $i++;
         }
         $rez = pg_query_params($this->_connectionID, $sql, $inputarr);
     } else {
         $rez = pg_query($this->_connectionID, $sql);
     }
     // check if no data returned, then no need to create real recordset
     if ($rez && pg_numfields($rez) <= 0) {
         if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
             pg_freeresult($this->_resultid);
         }
         $this->_resultid = $rez;
         return true;
     }
     return $rez;
 }
Пример #2
0
 function _query($sql, $inputarr = false)
 {
     if (!$this->_bindInputArray) {
         // We don't have native support for parameterized queries, so let's emulate it at the parent
         return ADODB_postgres64::_query($sql, $inputarr);
     }
     $this->_pnum = 0;
     $this->_errorMsg = false;
     // -- added Cristiano da Cunha Duarte
     if ($inputarr) {
         $sqlarr = explode('?', trim($sql));
         $sql = '';
         $i = 1;
         $last = sizeof($sqlarr) - 1;
         $localedata = localeconv();
         foreach ($sqlarr as $v) {
             if ($last < $i) {
                 $sql .= $v;
             } else {
                 $sql .= $v . ' $' . $i;
             }
             $i++;
             // pg_query_params may incorrectly format
             // doubles using localized number formats, i.e.
             // , instead of . for floats, violating the
             // SQL standard. Format it locally.
             $k = $i - 2;
             // Use proper index for $inputarr to avoid going over the end
             if ($k < $last) {
                 if (gettype($inputarr[$k]) == 'double') {
                     $inputarr[$k] = str_replace($localedata['decimal_point'], '.', $inputarr[$k]);
                 }
             }
         }
         $rez = pg_query_params($this->_connectionID, $sql, $inputarr);
     } else {
         $rez = pg_query($this->_connectionID, $sql);
     }
     // check if no data returned, then no need to create real recordset
     if ($rez && pg_numfields($rez) <= 0) {
         if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
             pg_freeresult($this->_resultid);
         }
         $this->_resultid = $rez;
         return true;
     }
     return $rez;
 }