public function rds_fetch_array(&$result) { // return odbc_fetch_array($result); return odbc_next_result($result); /*$i=0; while($ligne = odbc_fetch_row($result)) { $i++; } if($i == 0)return -1; else return $i;*/ }
/** * Move the internal odbc result pointer to the next available result * * @param a valid fbsql result resource * * @access public * * @return true if a result is available otherwise return false */ function nextResult($result) { return @odbc_next_result($result); }
public function killProcesses() { $conn = $this->connect(); $result = []; $res = odbc_exec($conn, "SHOW TRANSACTIONS;"); if ($res) { while ($row = odbc_fetch_array($res)) { $result[] = $row; } } odbc_next_result($res); odbc_free_result($res); /* * not really working, unfortunately * * array (size=1) 0 => array (size=6) 'id' => string '1465827617822' (length=13) 'user' => string 'sapi_workspace_38' (length=17) 'session' => string '652836219206' (length=12) 'name' => string '876af646-61c8-4a2d-83a2-00f757ad1912' (length=36) 'started_on' => string '2016-06-13 14:20:17.822000' (length=26) 'state' => string 'running' (length=7) string 'SELECT SYSTEM$ABORT_TRANSACTION(1465827617822);' (length=47) array (size=1) 'SYSTEM$ABORT_TRANSACTION(1465827617822)' => string 'Could not abort txn: 1465827617822' (length=34) * * * deleting credentials/whole workspace works like a charm though * */ foreach ($result as $transaction) { try { odbc_exec($conn, 'SELECT SYSTEM$ABORT_TRANSACTION(' . $transaction['id'] . ');'); } catch (\Exception $e) { // ignore } } odbc_close($conn); }
function execute($Procedure, $RS = 0) { $this->Query_ID = $this->query($Procedure); if ($this->Query_ID) { for ($i = 0; $i < $RS; $i++) { odbc_next_result($this->Query_ID); } } return $this->Query_ID; }
} else { $sql_update_old_comments = "\n UPDATE Content SET\n content_title = ?,\n content_value = ?,\n content_creation_time = ?,\n content_createdby_user_key = -2,\n content_edited_time = ?,\n content_editedby_user_key = -2,\n content_deleted = FALSE\n WHERE content_key = ?;\n "; if (!($stmt_update_comment = $mysqli_connection->prepare($sql_update_old_comments))) { echo "Prepare failed: (" . $mysqli_connection->errno . ") " . $mysqli_connection->error; } else { $stmt_update_comment->bind_param('ssssi', $row["content_title"], $row["content_value"], $row["creation_time"], $content_edited_time, $row["content_key"]); if (!$stmt_update_comment->execute()) { echo "Execute failed: (" . $stmt_update_comment->errno . ") " . $stmt_update_comment->error; } else { echo "updated {$row['content_title']}<br/>"; } } } } } } while (odbc_next_result($mssql_result)); // report no updates echo "<br/>"; if (empty($sql_insert_new_comments)) { echo "no new comments<br/><br/>"; } if (empty($sql_update_old_comments)) { echo "no updated comments<br/><br/>"; } if (empty($sql_delete_old_comments)) { echo "no deleted comments<br/><br/>"; } // close odbc_close_all(); } else { // help connecting to database
/** * Build db-specific report * @access: private */ function _sql_report($mode, $query = '') { switch ($mode) { case 'start': $explain_query = $query; if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) { $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; } else { if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) { $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; } } if (preg_match('/^SELECT/', $explain_query)) { $html_table = false; @odbc_exec($this->db_connect_id, "SET SHOWPLAN_TEXT ON;"); if ($result = @odbc_exec($this->db_connect_id, $explain_query)) { @odbc_next_result($result); while ($row = @odbc_fetch_array($result)) { $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); } } @odbc_exec($this->db_connect_id, "SET SHOWPLAN_TEXT OFF;"); @odbc_free_result($result); if ($html_table) { $this->html_hold .= '</table>'; } } break; case 'fromcache': $endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1]; $result = @odbc_exec($this->db_connect_id, $query); while ($void = @odbc_fetch_array($result)) { // Take the time spent on parsing rows into account } @odbc_free_result($result); $splittime = explode(' ', microtime()); $splittime = $splittime[0] + $splittime[1]; $this->sql_report('record_fromcache', $query, $endtime, $splittime); break; } }
/** * Move the internal result pointer to the next available result * * @return true on success, false if there is no more result set or an error object on failure * @access public */ function nextResult() { if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__); } elseif (is_null($this->result)) { return false; } return odbc_next_result($this->result); }