public function execute($sql, $bindParams = array(), $additionalParameters = array()) { $connection = $this->connection; if (empty($bindParams)) { $result = ibase_query($connection, $sql); } else { $holderRegex = "/@[a-zA-Z0-9_]+@/"; preg_match_all($holderRegex, $sql, $matches); $args = array($connection, preg_replace($holderRegex, "?", $sql)); foreach ($matches[0] as $holder) { $args[] = $bindParams[$holder]; } $result = call_user_func_array("ibase_query", $args); } if (!$result) { $this->executeError($sql); } $rows = array(); if (is_resource($result)) { while ($row = ibase_fetch_assoc($result, IBASE_TEXT)) { $rows[] = array_change_key_case($row); } ibase_free_result($result); } else { $this->affectedRows = $result === true ? 0 : $result; } if ($this->autoCommit) { ibase_commit($connection); } return empty($rows) ? null : $rows; }
protected function execute_query_trans($trans, $sql) { if ($exec = ibase_query($trans, $sql)) return $exec; //$this->gravaQueryArquivo($sql); return false; }
function recupera_campo($campo,$tabela,$campo_condicao,$condicao) { $consulta = "SELECT $campo FROM $tabela WHERE $campo_condicao = $condicao"; $resultado = ibase_query($consulta); $registro = ibase_fetch_object($resultado); $campo = $registro->$campo; return $campo; }
public function real($sql) { $this->connect(); $temp = \ibase_query($this->transaction !== null ? $this->transaction : $this->lnk, $sql); if (!$temp) { throw new DatabaseException('Could not execute query : ' . \ibase_errmsg() . ' <' . $sql . '>'); } $this->aff = \ibase_affected_rows($this->lnk); return $temp; }
protected function QueryObtieneDatos() { $this->AbreCnx(); //echo $this->query; $rs = ibase_query($this->cnx, $this->query); return $this->FetchAs($rs); //var_dump($rs); //echo $this->query; unset($this->query); $this->CierraCnx(); }
function Buscar($q) { $conn = ibase_connect($this->src, $this->user, $this->password); $query = "SELECT INVE03.CVE_ART, INVE03.DESCR FROM inve03 where INVE03.DESCR LIKE '%" . $q . "%' AND INVE03.STATUS='A' OR INVE03.CVE_ART LIKE '%" . $q . "%' AND INVE03.STATUS='A' ORDER BY INVE03.CVE_ART"; $inv = ibase_query($conn, $query); print "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='font-family:Verdana; font-size:10; font-color:#CDCD'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td></td>\n\t\t\t\t</tr>"; while ($IN = ibase_fetch_row($inv)) { print "<tr>" . "<td>" . $IN[1] . "</td>" . "<td><input style='border:0; background-color: #f9f9f9; font-family:Verdana; font-size:10; font-color:#CDCD; cursor:pointer' type='submit' id='valor2' value='" . $IN[0] . "' onClick='Resultado(\"" . $IN[0] . "\");'/></td>" . "</tr>"; } print "</table>"; }
public function executeQuery($sql) { try { $this->openConnection(); $this->rtemp = ibase_query($this->connection, $sql); while ($row = ibase_fetch_object($this->rtemp)) { $this->result[] = $row; } $this->freeResult(); $this->closeConnection(); } catch (Exception $ex) { $this->logger->log("Exception while connection with firebird database... {$ex}"); } }
function query($query, $unbuffered = false) { $result = ibase_query($query, $this->_link); if (!$result) { $this->errno = ibase_errcode(); $this->error = ibase_errmsg(); return false; } $this->error = ""; if ($result === true) { $this->affected_rows = ibase_affected_rows($this->_link); return true; } return new Min_Result($result); }
/** * Number of rows in the result set * * Firebird/Interbase doesn't have a graceful way to retun the number of rows * so we have to use what amounts to a hack. * * @access public * @return integer */ function num_rows() { if (!isset($this->sql)) { return 0; } else { $stmt_temp = $this->sql; $sth_temp = ibase_query($this->conn_id, $stmt_temp); $row_count = 0; while ($row_temp = ibase_fetch_object($sth_temp)) { $row_count = $row_count + 1; } ibase_free_result($sth_temp); return $row_count; } }
function simpleQuery($query) { $ismanip = DB::isManip($query); $this->last_query = $query; $query = $this->modifyQuery($query); $result = @ibase_query($this->connection, $query); if (!$result) { return $this->raiseError(); } if ($this->autocommit && $ismanip) { ibase_commit($this->connection); } // Determine which queries that should return data, and which // should return an error code only. return DB::isManip($query) ? DB_OK : $result; }
function deleteRow($table, $params) { $sql = 'delete from '; if (is_array($params)) { foreach ($params as $fieldname => $id) { $sql .= ' ' . $table; $sql .= ' where ' . $fieldname . ' = ' . $id; } } //return $sql; $result = ibase_query($sql); if ($result) { return true; } else { return false; } }
function DBAQuery(&$db, $database_file, $query) { if (!function_exists("ibase_connect")) { return $db->SetError("DBA query", "Interbase support is not available in this PHP configuration"); } if (!isset($db->options[$option = "DBAUser"]) || !isset($db->options[$option = "DBAPassword"])) { return $db->SetError("DBA query", "it was not specified the Interbase {$option} option"); } $database = $db->host . (strcmp($database_file, "") ? ":" . $database_file : ""); if (($connection = @ibase_connect($database, $db->options["DBAUser"], $db->options["DBAPassword"])) <= 0) { return $db->SetError("DBA query", "Could not connect to Interbase server ({$database}): " . ibase_errmsg()); } if (!($success = @ibase_query($connection, $query))) { $db->SetError("DBA query", "Could not execute query ({$query}): " . ibase_errmsg()); } ibase_close($connection); return $success; }
/** * This function initializes the class. * * @access public * @override * @param DB_Connection_Driver $connection the connection to be used * @param string $sql the SQL statement to be queried * @param integer $mode the execution mode to be used * @throws Throwable_SQL_Exception indicates that the query failed */ public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL) { $this->resource = $connection->get_resource(); $command = @ibase_query($this->resource, $sql); if ($command === FALSE) { throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @ibase_errmsg())); } $this->command = $command; $this->record = FALSE; $this->blobs = array(); $count = (int) @ibase_num_fields($command); for ($i = 0; $i < $count; $i++) { $field = ibase_field_info($command, $i); if ($field['type'] == 'BLOB') { $this->blobs[] = $field['name']; } } }
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true) { if ($show_errors) { error_reporting(E_ALL); } else { error_reporting(E_PARSE); } // Connect to the Firebird/Interbase Sybase database management system $link = ibase_pconnect("/var/www/sqlmap/dbs/firebird/testdb.fdb", "SYSDBA", "testpass"); if (!$link) { die(ibase_errmsg()); } // Print results in HTML print "<html><body>\n"; // Print SQL query to test sqlmap '--string' command line option //print "<b>SQL query:</b> " . $query . "<br>\n"; // Perform SQL injection affected query $result = ibase_query($link, $query); if (!$result) { if ($show_errors) { print "<b>SQL error:</b> " . ibase_errmsg() . "<br>\n"; } exit(1); } print "<b>SQL results:</b>\n"; print "<table border=\"1\">\n"; while ($line = ibase_fetch_assoc($result)) { // This must stay here for Firebird if (!$show_output) { exit(1); } print "<tr>"; foreach ($line as $col_value) { print "<td>" . $col_value . "</td>"; } print "</tr>\n"; if (!$all_results) { break; } } print "</table>\n"; print "</body></html>"; }
function gcms_query($query) { global $fbdb, $gcms_query_result, $gcms_trans_id; $xid = $gcms_trans_id; if (!$xid) { gcms_trans(); } $gcms_query_result = ibase_query($fbdb, $query); if (!$xid) { if ($gcms_query_result) { gcms_commit(); } else { gcms_rollback(); } } if (!$gcms_query_result) { print "<br>" . $query . "<br><br>"; } return $gcms_query_result; }
$ABR = 'CUU'; } if ($num_suc == 9) { $conn = Connectqro(); $ABR = 'QRO'; } if ($num_suc == 10) { $conn = Connecttgz(); $ABR = 'TGZ'; } if ($clave == '') { $sql = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, MINVE03.CANT AS CANTIDAD, MINVE03.EXISTENCIA FROM MINVE03 WHERE MINVE03.REFER ='{$folio}' ORDER BY MINVE03.CVE_ART DESC "; } else { $sql = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, MINVE03.CANT AS CANTIDAD, MINVE03.EXISTENCIA FROM MINVE03 WHERE MINVE03.REFER ='{$folio}' and MINVE03.CVE_ART='{$clave}' ORDER BY MINVE03.CVE_ART DESC "; } $conexsuc = ibase_query($conn, $sql); while ($CS = ibase_fetch_row($conexsuc)) { $fechasal = $CS[2]; $maskSAL = $fechasal[8] . $fechasal[9] . $fechasal[7] . $fechasal[5] . $fechasal[6] . $fechasal[4] . $fechasal[0] . $fechasal[1] . $fechasal[2] . $fechasal[3]; if ($CS[1] > '50') { $cant = $CS[4] * -1; $restacant = $restacant + $cant; } else { $cant = $CS[4]; $sumacant = $sumacant + $cant; } /* echo "<tr class='content'><td>$CS[0]</td><td>$CS[3]</td><td align='center'>$cant</td><td>$maskSAL</td><td>$CS[1]</td><td>$ABR</td></tr>"; $count = $count + 1; */ $registros[$num]["clave"] = $CS[0];
/** * Returns information about a table or a result set * * NOTE: only supports 'table' and 'flags' if <var>$result</var> * is a table name. * * @param object|string $result DB_result object from a query or a * string containing the name of a table. * While this also accepts a query result * resource identifier, this behavior is * deprecated. * @param int $mode a valid tableInfo mode * * @return array an associative array with the information requested. * A DB_Error object on failure. * * @see DB_common::tableInfo() */ function tableInfo($result, $mode = null) { if (is_string($result)) { /* * Probably received a table name. * Create a result resource identifier. */ $id = @ibase_query($this->connection, "SELECT * FROM {$result} WHERE 1=0"); $got_string = true; } elseif (isset($result->result)) { /* * Probably received a result object. * Extract the result resource identifier. */ $id = $result->result; $got_string = false; } else { /* * Probably received a result resource identifier. * Copy it. * Deprecated. Here for compatibility only. */ $id = $result; $got_string = false; } if (!is_resource($id)) { return $this->ibaseRaiseError(DB_ERROR_NEED_MORE_DATA); } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) { $case_func = 'strtolower'; } else { $case_func = 'strval'; } $count = @ibase_num_fields($id); $res = array(); if ($mode) { $res['num_fields'] = $count; } for ($i = 0; $i < $count; $i++) { $info = @ibase_field_info($id, $i); $res[$i] = array('table' => $got_string ? $case_func($result) : '', 'name' => $case_func($info['name']), 'type' => $info['type'], 'len' => $info['length'], 'flags' => $got_string ? $this->_ibaseFieldFlags($info['name'], $result) : ''); if ($mode & DB_TABLEINFO_ORDER) { $res['order'][$res[$i]['name']] = $i; } if ($mode & DB_TABLEINFO_ORDERTABLE) { $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; } } // free the result only if we were called on a table if ($got_string) { @ibase_free_result($id); } return $res; }
$unit = $row[2]; $charlimits = str_replace('%', '\\%', $row[3]); $charlimits = str_replace('^', '\\^{}', $charlimits); $ress = $row[1]; if ($row[4] == "O") { $ress = "\\textbf{" . $row[1] . "}"; } $results .= "~ \\footnotesize " . $row[0] . " & \\footnotesize " . $ress . " & \\footnotesize " . $unit . " \\\\ \n"; $results .= "\\hline" . "\n"; } ibase_free_result($res); } } } $user = getUserEnterResults($ordersid, $dbh); $appruser = getApprUser($ordersid, $dbh); $comments = ""; $restm = "select distinct f.comments from foldercomments f inner join orders o on o.folderno = f.folderno where o.id in(" . $ordersid . ") and f.flag = 'Y' order by f.id"; $res = ibase_query($dbh, $restm); while ($row = ibase_fetch_row($res)) { $comments .= "\\small \\quad " . $row[0] . "\n\n"; } ibase_free_result($res); $biomat = find_biomat($ordersid, $dbh); $head = "\\SetWatermarkText{" . $watermark . "}\n"; $head .= "\\vspace{-10px} \\flushleft \\normalsize Биоматериал: " . $biomat . "\n\n\\vspace{3px}"; $head .= "\n\\begin{longtable}[h]{|m{230px}|>{\\centering\\arraybackslash}p{140px}|m{90px}|}\n\\hline\nИсследование & Результат & Единицы \\newline измерения \\\\\n\\hline"; $apprdate = find_apprdate($ordersid, $dbh); $comments = str_replace('%', '\\%', $comments); $end = "\\end{longtable}\n\\vspace{-15px}\n\\flushleft Комментарии:" . $comments . "\n\\vspace{-4px}\n\\flushleft Исследования проводил: " . $user . " \n\\vspace{-4px}\n\\flushleft Выпускающий врач: " . $appruser . " \n\\newline\n\\flushright Дата выдачи: " . $apprdate; $response = $head . $results . $end;
function DoQuery($query, $first = 0, $limit = 0, $prepared_query = 0) { $connection = $this->auto_commit ? $this->connection : $this->transaction_id; if ($prepared_query && isset($this->query_parameters[$prepared_query]) && count($this->query_parameters[$prepared_query]) > 2) { if (function_exists("call_user_func_array")) { $this->query_parameters[$prepared_query][0] = $connection; $this->query_parameters[$prepared_query][1] = $query; $result = @call_user_func_array("ibase_query", $this->query_parameters[$prepared_query]); } else { switch (count($this->query_parameters[$prepared_query])) { case 3: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2]); break; case 4: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2], $this->query_parameters[$prepared_query][3]); break; case 5: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2], $this->query_parameters[$prepared_query][3], $this->query_parameters[$prepared_query][4]); break; case 6: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2], $this->query_parameters[$prepared_query][3], $this->query_parameters[$prepared_query][4], $this->query_parameters[$prepared_query][5]); break; case 7: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2], $this->query_parameters[$prepared_query][3], $this->query_parameters[$prepared_query][4], $this->query_parameters[$prepared_query][5], $this->query_parameters[$prepared_query][6]); break; case 8: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2], $this->query_parameters[$prepared_query][3], $this->query_parameters[$prepared_query][4], $this->query_parameters[$prepared_query][5], $this->query_parameters[$prepared_query][6], $this->query_parameters[$prepared_query][7]); break; case 9: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2], $this->query_parameters[$prepared_query][3], $this->query_parameters[$prepared_query][4], $this->query_parameters[$prepared_query][5], $this->query_parameters[$prepared_query][6], $this->query_parameters[$prepared_query][7], $this->query_parameters[$prepared_query][8]); break; case 10: $result = @ibase_query($connection, $query, $this->query_parameters[$prepared_query][2], $this->query_parameters[$prepared_query][3], $this->query_parameters[$prepared_query][4], $this->query_parameters[$prepared_query][5], $this->query_parameters[$prepared_query][6], $this->query_parameters[$prepared_query][7], $this->query_parameters[$prepared_query][8], $this->query_parameters[$prepared_query][9]); break; } } } else { $result = @ibase_query($connection, $query); } if ($result) { if ($select = substr(strtolower(ltrim($query)), 0, strlen("select")) == "select") { $result_value = intval($result); $this->current_row[$result_value] = -1; if ($limit > 0) { $this->limits[$result_value] = array($first, $limit, 0); } $this->highest_fetched_row[$result_value] = -1; } else { $this->affected_rows = -1; } } else { return $this->SetError("Do query", "Could not execute query ({$query}): " . ibase_errmsg()); } return $result; }
/** * Execute the query * * @param string $sql an SQL query * @return resource */ protected function _execute($sql) { return ibase_query($this->conn_id, $sql); }
/** * Returns the ID generated from the previous INSERT operation. * * @param unknown_type $source * @return in */ function lastInsertId($source = null, $field = 'id') { $query = "SELECT RDB\$TRIGGER_SOURCE\n\t\tFROM RDB\$TRIGGERS WHERE RDB\$RELATION_NAME = '" . strtoupper($source) . "' AND\n\t\tRDB\$SYSTEM_FLAG IS NULL AND RDB\$TRIGGER_TYPE = 1 "; $result = @ibase_query($this->connection, $query); $generator = ""; while ($row = ibase_fetch_row($result, IBASE_TEXT)) { if (strpos($row[0], "NEW." . strtoupper($field))) { $pos = strpos($row[0], "GEN_ID("); if ($pos > 0) { $pos2 = strpos($row[0], ",", $pos + 7); if ($pos2 > 0) { $generator = substr($row[0], $pos + 7, $pos2 - $pos - 7); } } break; } } if (!empty($generator)) { $sql = "SELECT GEN_ID(" . $generator . ",0) AS maxi FROM RDB" . "\$" . "DATABASE"; $res = $this->rawQuery($sql); $data = $this->fetchRow($res); return $data['maxi']; } else { return false; } }
/** * Execute any statement * * @param string sql * @param bool buffered default TRUE * @return rdbms.ResultSet * @throws rdbms.SQLException */ protected function query0($sql, $buffered = true) { if (!is_resource($this->handle)) { if (!($this->flags & DB_AUTOCONNECT)) { throw new \rdbms\SQLStateException('Not connected'); } $c = $this->connect(); // Check for subsequent connection errors if (false === $c) { throw new \rdbms\SQLStateException('Previously failed to connect'); } } $result = ibase_query($sql, $this->handle); if (false === $result) { $message = 'Statement failed: ' . trim(ibase_errmsg()) . ' @ ' . $this->dsn->getHost(); $code = ibase_errcode(); switch ($code) { case -924: // Connection lost throw new \rdbms\SQLConnectionClosedException($message, $sql); case -913: // Deadlock throw new \rdbms\SQLDeadlockException($message, $sql, $code); default: // Other error throw new \rdbms\SQLStatementFailedException($message, $sql, $code); } } else { if (true === $result) { return new QuerySucceeded(ibase_affected_rows($this->handle)); } else { return new InterBaseResultSet($result, $this->tz); } } }
/** * Efectua operaciones SQL sobre la base de datos * * @param string $sqlQuery * @return resource or false */ public function query($sql_query) { $this->debug($sql_query); if ($this->logger) { Logger::debug($sql_query); } if (!$this->id_connection) { $this->connect(); if (!$this->id_connection) { return false; } } $this->last_query = $sql_query; if ($result_query = @ibase_query($sql_query)) { $this->last_result_query = $result_query; return $result_query; } else { $this->last_result_query = false; throw new KumbiaException($this->error(" al ejecutar <em>\"{$sql_query}\"</em>")); } }
if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { $dados = array('nome' => filter_var($_POST['nome'], FILTER_SANITIZE_STRING), 'email' => filter_var($_POST['email'], FILTER_SANITIZE_EMAIL), 'senha' => empty($_POST['senha']) ? $usuario_logado->SENHA : sha1(md5($_POST['senha']))); $sql = "INSERT INTO usuarios(id, nome, email, senha) VALUES ((SELECT iif(MAX(id) > 0, MAX(id), 0) FROM usuarios) + 1, '{$dados['nome']}', '{$dados['email']}', '{$dados['senha']}') RETURNING id"; if ($rotas['id']) { $sql = "UPDATE usuarios SET nome = '{$dados['nome']}', email = '{$dados['email']}', senha = '{$dados['senha']}' WHERE id = '{$usuario_logado->ID}' RETURNING id"; } $query = ibase_query($conexao, $sql); $resultado = ibase_fetch_object($query); if ($resultado) { header("Location: {$base}/index.php/{$rotas['pagina']}/formulario/{$resultado->ID}"); } echo 'Houve um erro ao salvar os dados. Tente novamente.<br/>' . ibase_errmsg(); } if ($rotas['id']) { $sql = "SELECT * FROM usuarios WHERE id = '{$rotas['id']}'"; $query = ibase_query($conexao, $sql); $dados = ibase_fetch_assoc($query); $dados = array_change_key_case($dados, CASE_LOWER); } ?> <h2><?php echo $rotas['id'] ? 'Editar' : 'Criar novo'; ?> usuario</h2> <form action="" method="post"> <label>Nome</label><br/> <input required name="nome" value="<?php echo $dados['nome']; ?> " placeholder="Nome" type="text" /><br/><br/> <label>E-mail</label><br/>
/** * Executes a SQL query. * * <b>Note:</b> Use the {@link dbi_error()} function to get error information * if the connection fails. * * @param string $sql SQL of query to execute * @param bool $fatalOnError Abort execution if there is a database error? * @param bool $showError Display error to user (including possibly the * SQL) if there is a database error? * * @return mixed The query result resource on queries (which can then be * passed to the {@link dbi_fetch_row()} function to obtain the * results), or true/false on insert or delete queries. */ function dbi_query($sql, $fatalOnError = true, $showError = true) { global $phpdbiVerbose; if (strcmp($GLOBALS["db_type"], "mysql") == 0) { $res = mysql_query($sql); if (!$res) { dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError); } return $res; } else { if (strcmp($GLOBALS["db_type"], "mysqli") == 0) { $res = mysqli_query($GLOBALS["db_connection"], $sql); if (!$res) { dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError); } return $res; } else { if (strcmp($GLOBALS["db_type"], "mssql") == 0) { $res = mssql_query($sql); if (!$res) { dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError); } return $res; } else { if (strcmp($GLOBALS["db_type"], "oracle") == 0) { $GLOBALS["oracle_statement"] = OCIParse($GLOBALS["oracle_connection"], $sql); return OCIExecute($GLOBALS["oracle_statement"], OCI_COMMIT_ON_SUCCESS); } else { if (strcmp($GLOBALS["db_type"], "postgresql") == 0) { @($GLOBALS["postgresql_row[\"{$res}\"]"] = 0); $res = pg_exec($GLOBALS["postgresql_connection"], $sql); if (!$res) { dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError); } $GLOBALS["postgresql_numrows[\"{$res}\"]"] = pg_numrows($res); return $res; } else { if (strcmp($GLOBALS["db_type"], "odbc") == 0) { return odbc_exec($GLOBALS["odbc_connection"], $sql); } else { if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) { $res = db2_exec($GLOBALS["ibm_db2_connection"], $sql); if (!$res) { dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError); } return $res; } else { if (strcmp($GLOBALS["db_type"], "ibase") == 0) { $res = ibase_query($sql); if (!$res) { dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError); } return $res; } else { dbi_fatal_error("dbi_query(): db_type not defined."); } } } } } } } } }
/** +---------------------------------------------------------- * 取得数据表的字段信息 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ public function getFields($tableName) { $result = $this->query('SELECT RDB$FIELD_NAME AS FIELD, RDB$DEFAULT_VALUE AS DEFAULT1, RDB$NULL_FLAG AS NULL1 FROM RDB$RELATION_FIELDS WHERE RDB$RELATION_NAME=UPPER(\'' . $tableName . '\') ORDER By RDB$FIELD_POSITION'); $info = array(); if ($result) { foreach ($result as $key => $val) { $info[trim($val['FIELD'])] = array('name' => trim($val['FIELD']), 'type' => '', 'notnull' => (bool) ($val['NULL1'] == 1), 'default' => $val['DEFAULT1'], 'primary' => false, 'autoinc' => false); } } //剑雷 取表字段类型 $sql = 'select first 1 * from ' . $tableName; $rs_temp = ibase_query($this->_linkID, $sql); $fieldCount = ibase_num_fields($rs_temp); for ($i = 0; $i < $fieldCount; $i++) { $col_info = ibase_field_info($rs_temp, $i); $info[trim($col_info['name'])]['type'] = $col_info['type']; } ibase_free_result($rs_temp); //剑雷 取表的主键 $sql = 'select b.rdb$field_name as FIELD_NAME from rdb$relation_constraints a join rdb$index_segments b on a.rdb$index_name=b.rdb$index_name where a.rdb$constraint_type=\'PRIMARY KEY\' and a.rdb$relation_name=UPPER(\'' . $tableName . '\')'; $rs_temp = ibase_query($this->_linkID, $sql); while ($row = ibase_fetch_object($rs_temp)) { $info[trim($row->FIELD_NAME)]['primary'] = True; } ibase_free_result($rs_temp); return $info; }
$ent = ibase_query($conn2, $sql2); while ($E = ibase_fetch_row($ent)) { if ($S[2] == $E[2] and $S[0] == $E[0]) { $fechasale = ibase_query($conn, $sqlF); while ($F = ibase_fetch_row($fechasale)) { if ($S[2] == $F[2] and $S[0] == $F[0]) { $encontro = $F[1]; } } $cantDifsal = ibase_query($conn, $sql3); while ($SD = ibase_fetch_row($cantDifsal)) { if ($S[2] == $SD[2] and $S[0] == $SD[0]) { $difSal = $SD[3]; } } $cantDifent = ibase_query($conn2, $sql4); while ($SE = ibase_fetch_row($cantDifent)) { if ($E[2] == $SE[2] and $E[0] == $SE[0]) { $difEnt = $SE[3]; } } //Calculo diferencias en montos de Salidas $maskCantS = $S[3] * -1; $totalDifsal = $maskCantS + $difSal; $totalDifent = $E[3] - $difEnt; $dif = $totalDifsal + $totalDifent; $fechasal = $encontro; $maskSAL = $fechasal[8] . $fechasal[9] . $fechasal[7] . $fechasal[5] . $fechasal[6] . $fechasal[4] . $fechasal[0] . $fechasal[1] . $fechasal[2] . $fechasal[3]; $count = $count + 1; if ($dif == 0) { echo "<tr style='font-size:9px; color:#000000'><td style='font-family:Verdana'>{$count}</td><td style='font-family:Consolas;font-size:11px'>{$S['0']}</td><td style='font-family:Verdana'>{$S['2']}</td><td align='center' style='font-family:Verdana'>{$totalDifsal}</td><td align='center' style='font-family:Verdana'>{$maskSAL}</td><td style='font-family:Verdana'>{$E['2']}</td><td align='center' style='font-family:Verdana'>{$totalDifent}</td><td style='font-family:Verdana'>{$dif}</td>";
function sql_report($mode, $query = '') { if (empty($_GET['explain'])) { return; } global $cache, $starttime, $phpbb_root_path; static $curtime, $query_hold, $html_hold; static $sql_report = ''; static $cache_num_queries = 0; if (!$query && !empty($query_hold)) { $query = $query_hold; } switch ($mode) { case 'display': if (!empty($cache)) { $cache->unload(); } $this->sql_close(); $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n"; echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n"; echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n"; echo '</style><title>' . $msg_title . '</title></head><body>'; echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> </td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . ($cache_num_queries ? " + {$cache_num_queries} " . ($cache_num_queries == 1 ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>'; echo $sql_report; echo '</td></tr></table><br /></body></html>'; exit; break; case 'start': $query_hold = $query; $html_hold = ''; $curtime = explode(' ', microtime()); $curtime = $curtime[0] + $curtime[1]; break; case 'fromcache': $endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1]; $result = @ibase_query($this->db_connect_id, $query); while ($void = @ibase_fetch_object($result, IBASE_TEXT)) { // Take the time spent on parsing rows into account } $splittime = explode(' ', microtime()); $splittime = $splittime[0] + $splittime[1]; $time_cache = $endtime - $curtime; $time_db = $splittime - $endtime; $color = $time_db > $time_cache ? 'green' : 'red'; $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query results obtained from the cache</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\\t(AND|OR)(\\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\\s]*[\\n\\r\\t]+[\\n\\r\\s\\t]*/', "\n", $query))) . '</textarea></td></tr></table><p align="center">'; $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: <b style="color: ' . $color . '">' . sprintf('%.5f', $time_cache) . 's</b> | Elapsed [db]: <b>' . sprintf('%.5f', $time_db) . 's</b></p>'; // Pad the start time to not interfere with page timing $starttime += $time_db; @ibase_freeresult($result); $cache_num_queries++; break; case 'stop': $endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1]; $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\\t(AND|OR)(\\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\\s]*[\\n\\r\\t]+[\\n\\r\\s\\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">'; if ($this->query_result) { if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) { $sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | '; } $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>'; } else { $error = $this->sql_error(); $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); } $sql_report .= '</p>'; $this->sql_time += $endtime - $curtime; break; } }
function sti_firebird_get_data($connection_string, $data_source_name, $query) { $info = sti_firebird_parse_connection_string($connection_string); $link = ibase_connect($info["host"] . ":" . $info["database"], $info["user_id"], $info["password"]) or die("ServerError:Could not connect to host '" . $info["host"] . "', database '" . $info["database"] . "'"); $query = sti_parse_query_parameters($query); $result = ibase_query($link, $query) or die("ServerError:Data not found"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Database>"; $count = ibase_num_fields($result); for ($fid = 0; $fid < $count; $fid++) { $field_info = ibase_field_info($result, $fid); $columns[$fid] = $field_info['alias']; } while ($row = ibase_fetch_assoc($result)) { $xml_output .= "<{$data_source_name}>"; foreach ($columns as $column) { $value = $row[$column]; $value = str_replace("&", "&", $value); $value = str_replace("<", "<", $value); $value = str_replace(">", ">", $value); $xml_output .= "<{$column}>{$value}</{$column}>"; } $xml_output .= "</{$data_source_name}>"; } $xml_output .= "</Database>"; ibase_free_result($result); ibase_close($link); return $xml_output; }
$cuu = 1; } } //CONECTA QUERETARO $conn10 = Connectqro(); $sql10 = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, SUM(MINVE03.CANT) AS CANTIDAD FROM MINVE03 WHERE MINVE03.CVE_CPTO = 7 AND ((MINVE03.FECHA_DOCU)>='{$fecha}') and ((MINVE03.FECHA_DOCU)<='{$fechaf}') and MINVE03.CVE_ART='{$clave}' GROUP BY MINVE03.CVE_ART, MINVE03.CVE_CPTO,MINVE03.FECHA_DOCU,MINVE03.REFER ORDER BY MINVE03.REFER, MINVE03.CVE_ART, MINVE03.FECHA_DOCU ASC "; $ent10 = ibase_query($conn10, $sql10); while ($QRO = ibase_fetch_row($ent10)) { if ($S[3] == $QRO[3] and $S[0] == $QRO[0]) { $qro = 1; } } //CONECTA TUXTLA $conn11 = Connecttgz(); $sql11 = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, SUM(MINVE03.CANT) AS CANTIDAD FROM MINVE03 WHERE MINVE03.CVE_CPTO = 7 AND ((MINVE03.FECHA_DOCU)>='{$fecha}') and ((MINVE03.FECHA_DOCU)<='{$fechaf}') and MINVE03.CVE_ART='{$clave}' GROUP BY MINVE03.CVE_ART, MINVE03.CVE_CPTO,MINVE03.FECHA_DOCU,MINVE03.REFER ORDER BY MINVE03.REFER, MINVE03.CVE_ART, MINVE03.FECHA_DOCU ASC "; $ent11 = ibase_query($conn11, $sql11); while ($TGZ = ibase_fetch_row($ent11)) { if ($S[3] == $TGZ[3] and $S[0] == $TGZ[0]) { $tgz = 1; } } if ($mex == 0 and $gto == 0 and $gdl == 0 and $mty == 0 and $pue == 0 and $ver == 0 and $cun == 0 and $mid == 0 and $cuu == 0 and $qro == 0 and $tgz == 0) { echo "<tr><td>{$S['0']}</td><td>{$S['3']}</td>"; echo "<td>{$S['4']}</td>"; echo "<td>{$maskSAL}</td><td>Sin Coincidencia</td></tr>"; $count = $count + 1; } if ($mex == 1) { $mex = 0; } if ($gto == 1) {