function _affectedrows()
 {
     if ($this->lastQuery) {
         return @ifx_affected_rows($this->lastQuery);
     }
     return 0;
 }
Пример #2
0
 /**
  * Numero de Filas afectadas en un insert, update o delete
  *
  * @param resource $result_query
  * @return int
  */
 public function affected_rows($result_query = '')
 {
     if (!$result_query) {
         $result_query = $this->last_result_query;
         if (!$result_query) {
             return false;
         }
     }
     if (($numberRows = ifx_affected_rows($result_query)) !== false) {
         return $numberRows;
     } else {
         $this->lastError = $this->error();
         throw new KumbiaException($this->error());
     }
     return false;
 }
Пример #3
0
 /**
  * Send a query to Informix and return the results as a
  * Informix resource identifier.
  *
  * @param $query the SQL query
  *
  * @return int returns a valid Informix result for successful SELECT
  * queries, DB_OK for other successful queries.  A DB error code
  * is returned on failure.
  */
 function simpleQuery($query)
 {
     $this->last_query = $query;
     if (preg_match('/(SELECT)/i', $query)) {    //TESTME: Use !DB::isManip()?
         // the scroll is needed for fetching absolute row numbers
         // in a select query result
         $result = @ifx_query($query, $this->connection, IFX_SCROLL);
     } else {
         $result = @ifx_query($query, $this->connection);
     }
     if (!$result) {
         return $this->ifxraiseError();
     }
     $this->affected = ifx_affected_rows ($result);
     // Determine which queries that should return data, and which
     // should return an error code only.
     if (preg_match('/(SELECT)/i', $query)) {
         return $result;
     }
     return DB_OK;
 }
Пример #4
0
 /**
  * Sends a query to the database server
  *
  * @param string  the SQL query string
  *
  * @return mixed  + a PHP result resrouce for successful SELECT queries
  *                + the DB_OK constant for other successful queries
  *                + a DB_Error object on failure
  */
 function simpleQuery($query)
 {
     $ismanip = DB::isManip($query);
     $this->last_query = $query;
     $this->affected = null;
     if (preg_match('/(SELECT)/i', $query)) {
         //TESTME: Use !DB::isManip()?
         // the scroll is needed for fetching absolute row numbers
         // in a select query result
         $result = @ifx_query($query, $this->connection, IFX_SCROLL);
     } else {
         if (!$this->autocommit && $ismanip) {
             if ($this->transaction_opcount == 0) {
                 $result = @ifx_query('BEGIN WORK', $this->connection);
                 if (!$result) {
                     return $this->ifxRaiseError();
                 }
             }
             $this->transaction_opcount++;
         }
         $result = @ifx_query($query, $this->connection);
     }
     if (!$result) {
         return $this->ifxRaiseError();
     }
     $this->affected = @ifx_affected_rows($result);
     // Determine which queries should return data, and which
     // should return an error code only.
     if (preg_match('/(SELECT)/i', $query)) {
         return $result;
     }
     // XXX Testme: free results inside a transaction
     // may cause to stop it and commit the work?
     // Result has to be freed even with a insert or update
     @ifx_free_result($result);
     return DB_OK;
 }
Пример #5
0
 function DoQuery($query, $first = 0, $limit = 0, $free_non_select_result = 1, $prepared_query = 0)
 {
     ifx_nullformat(1);
     ifx_blobinfile_mode(0);
     $query = ltrim($query);
     if (GetType($space = strpos($query, " ")) != "integer") {
         $space = strlen($query);
     }
     $query_type = strtolower(substr($query, 0, $space));
     if (($select = $query_type == "select") && $limit > 0) {
         $query = substr($query, 0, $space) . " FIRST " . ($first + $limit) . " " . substr($query, strlen("select"));
         $cursor_type = $first ? IFX_SCROLL : 0;
     } else {
         $cursor_type = 0;
     }
     if ($prepared_query && isset($this->query_parameters[$prepared_query]) && count($this->query_parameters[$prepared_query])) {
         $result = $cursor_type ? @ifx_query($query, $this->connection, $cursor_type, $this->query_parameters[$prepared_query]) : @ifx_query($query, $this->connection, $this->query_parameters[$prepared_query]);
     } else {
         $result = $cursor_type ? @ifx_query($query, $this->connection, $cursor_type) : @ifx_query($query, $this->connection);
     }
     if ($result) {
         $result_value = intval($result);
         switch ($query_type) {
             case "select":
                 $this->current_row[$result_value] = -1;
                 if ($limit > 0) {
                     $this->limits[$result_value] = array($first, $limit, 0);
                 }
                 $this->highest_fetched_row[$result_value] = -1;
                 break;
             case "commit":
             case "rollback":
             case "begin":
             case "database":
                 ifx_free_result($result);
                 break;
             default:
                 $this->affected_rows = ifx_affected_rows($result);
                 if ($free_non_select_result) {
                     ifx_free_result($result);
                 }
                 break;
         }
     } else {
         $this->SetIFXError("Do query", "Could not query Informix database");
     }
     return $result;
 }
Пример #6
0
             $stringorderby_1_order[$posorderby_1_order][6] = '#CCFFCC';
             $posorderby_1_order = $posorderby_1_order + 1;
         }
     }
     //fin while
     ifx_free_result($g_idq);
 } else {
     if ($_SESSION['control_campos_co'] == 7) {
         // ubicación
         $bloqueo = "set isolation to dirty read";
         p_query($bloqueo);
         $vector_v_direcciones = array();
         $pos_vec_direcciones = 0;
         $sql = "SELECT g.t_direccion FROM v_direccion g " . $c_direccion2_vetor_dir;
         p_query($sql);
         $num = ifx_affected_rows($g_idq);
         $filas = 0;
         while ($registro = ifx_fetch_row($g_idq)) {
             $filas++;
             if ($filas == 1) {
                 $vector_v_direcciones[$pos_vec_direcciones][1] = $registro['t_direccion'];
                 $depurado = $registro['t_direccion'];
                 //echo "correcto-". $correcto=trim($depurado," ","\t","\n","\r","\0","\x0B","-",".","º","!","$","%","&","/","(",")","=","?","¿");
                 $correcto = str_replace("\t", " ", $depurado);
                 $correcto = str_replace("\n", " ", $correcto);
                 $correcto = str_replace("\r", " ", $correcto);
                 $correcto = str_replace("", " ", $correcto);
                 $correcto = str_replace("\v", " ", $correcto);
                 $correcto = str_replace("-", " ", $correcto);
                 $correcto = str_replace(".", " ", $correcto);
                 $correcto = str_replace("º", " ", $correcto);