public function getQueryCount($qtxt) { $link = $this->getDB(); $qtxt = iconv("utf-8", "gbk//ignore", $qtxt); $query = sybase_query("exec llt_searchByPageCount " . "'" . $qtxt . "'", $link); $row = sybase_fetch_array($query); return $row[0]; }
/** * Process connect events. * * @param var observable * @param var dbevent */ public function onConnect($obs, $arg) { ini_set('sybct.min_server_severity', 0); sybase_set_message_handler(array($this, '_msghandler'), $obs->handle); sybase_query('set statistics io on', $obs->handle); // Reset query- and message-cache $this->queries = $this->messages = array(); }
/** * Process connect events. * * @param var observable * @param var dbevent */ public function onConnect($obs, $arg) { ini_set('sybct.min_server_severity', 0); sybase_set_message_handler([$this, '_msghandler'], $obs->handle); sybase_query('set showplan on', $obs->handle); // Reset query- and message-cache $this->queries = $this->messages = []; }
protected function _execute() { $query = $this->_build_query(); if (!$query) { return false; } $this->_result = @sybase_query($query, $this->_link); if (!$this->_result) { $this->_set_stmt_error(null, PDO::ERRMODE_SILENT, 'execute'); return false; } return true; }
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 Sybase database management system $link = @sybase_pconnect("192.168.231.144", "testuser", "testpass"); if (!$link) { die(sybase_get_last_message()); } // Make 'testdb' the current database $db_selected = @sybase_select_db("testdb"); if (!$db_selected) { die(sybase_get_last_message()); } // 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 = sybase_query($query); if (!$result) { if ($show_errors) { print "<b>SQL error:</b> " . sybase_get_last_message() . "<br>\n"; } exit(1); } if (!$show_output) { exit(1); } print "<b>SQL results:</b>\n"; print "<table border=\"1\">\n"; while ($line = sybase_fetch_assoc($result)) { 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 select($fields, $tables, $where = "", $order_by = "", $group_by = "", $having = "") { $sql_stat = " select {$fields} from {$tables} "; if (!empty($where)) { $sql_stat .= "where {$where} "; } if (!empty($group_by)) { $sql_stat .= "group by {$group_by} "; } if (!empty($order_by)) { $sql_stat .= "order by {$order_by} "; } if (!empty($having)) { $sql_stat .= "having {$having} "; } $this->db_result = @sybase_query($sql_stat) or print "Error"; $this->db_affected_rows = @sybase_num_rows($this->db_result); return $sql_stat; }
protected function _query($query) { global $configArray; if (strcasecmp($configArray['System']['operatingSystem'], 'windows') == 0) { return sybase_query($query); } else { return mssql_query($query); } }
function query($query) { //if flag to convert query from MySql syntax to Sybase syntax is true //convert the query if ($this->convertMySqlTosybaseQuery == true) { $query = $this->ConvertMySqlTosybase($query); } // Initialise return $return_val = 0; // Flush cached values.. $this->flush(); // For reg expressions $query = trim($query); // Log how the function was called $this->func_call = "\$db->query(\"{$query}\")"; // Keep track of the last query for debug.. $this->last_query = $query; // Count how many queries there have been $this->num_queries++; // Use core file cache function if ($cache = $this->get_cache($query)) { return $cache; } // If there is no existing database connection then try to connect if (!isset($this->dbh) || !$this->dbh) { $this->connect($this->dbuser, $this->dbpassword, $this->dbhost); $this->select($this->dbname); } // Perform the query via std sybase_query function.. $this->result = @sybase_query($query); // If there is an error then take note of it.. if ($this->result == false) { $get_errorcodeSql = "SELECT @@ERROR as errorcode"; $error_res = @sybase_query($get_errorcodeSql, $this->dbh); $errorCode = @sybase_result($error_res, 0, "errorcode"); $get_errorMessageSql = "SELECT severity as errorSeverity, text as errorText FROM sys.messages WHERE message_id = " . $errorCode; $errormessage_res = @sybase_query($get_errorMessageSql, $this->dbh); if ($errormessage_res) { $errorMessage_Row = @sybase_fetch_row($errormessage_res); $errorSeverity = $errorMessage_Row[0]; $errorMessage = $errorMessage_Row[1]; } $sqlError = "ErrorCode: " . $errorCode . " ### Error Severity: " . $errorSeverity . " ### Error Message: " . $errorMessage . " ### Query: " . $query; $is_insert = true; $this->register_error($sqlError); $this->show_errors ? trigger_error($sqlError, E_USER_WARNING) : null; return false; } // Query was an insert, delete, update, replace $is_insert = false; if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) { $this->rows_affected = @sybase_rows_affected($this->dbh); // Take note of the insert_id if (preg_match("/^(insert|replace)\\s+/i", $query)) { $identityresultset = @sybase_query("select SCOPE_IDENTITY()"); if ($identityresultset != false) { $identityrow = @sybase_fetch_row($identityresultset); $this->insert_id = $identityrow[0]; } } // Return number of rows affected $return_val = $this->rows_affected; } else { // Take note of column info $i = 0; while ($i < @sybase_num_fields($this->result)) { $this->col_info[$i] = @sybase_fetch_field($this->result); $i++; } // Store Query Results $num_rows = 0; while ($row = @sybase_fetch_object($this->result)) { // Store relults as an objects within main array $this->last_result[$num_rows] = $row; $num_rows++; } @sybase_free_result($this->result); // Log number of rows the query returned $this->num_rows = $num_rows; // Return number of rows selected $return_val = $this->num_rows; } // disk caching of queries $this->store_cache($query, $is_insert); // If debug ALL queries $this->trace || $this->debug_all ? $this->debug() : null; return $return_val; }
/** * Execute any statement * * @param string sql * @param bool buffered default TRUE * @return rdbms.sybase.SybaseResultSet or TRUE if no resultset was created * @throws rdbms.SQLException */ protected function query0($sql, $buffered = TRUE) { if (!is_resource($this->handle)) { if (!($this->flags & DB_AUTOCONNECT)) { throw new SQLStateException('Not connected'); } $c = $this->connect(); // Check for subsequent connection errors if (FALSE === $c) { throw new SQLStateException('Previously failed to connect'); } } if (!$buffered) { $result = @sybase_unbuffered_query($sql, $this->handle, FALSE); } else { if ($this->flags & DB_UNBUFFERED) { $result = @sybase_unbuffered_query($sql, $this->handle, $this->flags & DB_STORE_RESULT); } else { $result = @sybase_query($sql, $this->handle); } } if (FALSE === $result) { $message = 'Statement failed: ' . trim(sybase_get_last_message()) . ' @ ' . $this->dsn->getHost(); if (!is_resource($error = sybase_query('select @@error', $this->handle))) { // The only case selecting @@error should fail is if we receive a // disconnect. We could also check on the warnings stack if we can // find the following: // // Sybase: Client message: Read from SQL server failed. (severity 78) // // but that seems a bit errorprone. throw new SQLConnectionClosedException($message, $sql); } $code = current(sybase_fetch_row($error)); switch ($code) { case 1205: // Deadlock throw new SQLDeadlockException($message, $sql, $code); default: // Other error throw new SQLStatementFailedException($message, $sql, $code); } } return TRUE === $result ? $result : new SybaseResultSet($result, $this->tz); }
public function rollBack() { parent::rollback(); if (!sybase_query('ROLLBACK', $this->link)) { $this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, 'rollBack'); } $this->setAttribute(PDO::ATTR_AUTOCOMMIT, $this->driver_options[PDO::ATTR_AUTOCOMMIT]); return true; }
function query_sybase($query) { if (!$this->sybase_link) { return false; } $this->query_result = sybase_query($query, $this->sybase_link); if ($this->query_result) { return $this->query_result; } else { print nl2br("Error query. \n"); return false; } }
<?php //phpinfo(); $link = @sybase_connect('lltang2000', 'sa', '******') or die("Could not connect !"); //连接数据库,第一空必须写服务名称,不能是ip; echo "Connected successfully<br>"; $db = @sybase_select_db("sulcmis", $link) or die("数据库没有选择"); echo "数据库选择成功<br>"; $sql = "select ctrlNo,F200,F210c from b_brief where ctrlNo<100"; $rs = sybase_query($sql, $link); //查询表 if (!$rs) { echo "SQL:" . $sql . "执行失败!"; exit; } //$sybase = sybase_fetch_array($rs); //print_r($sybase);//结束 echo '<table border="1"><tr><td>CtrlNO</td><td>F200</td><td>F210c</td>'; while ($row = sybase_fetch_array($rs)) { $id = $row["ctrlNo"]; $F200 = $row["F200"]; $F210c = $row["F210c"]; echo '<tr><td>' . $id . '</td><td>' . $F200 . '</td><td>' . $F210c . '</td></tr>'; } echo '</table>'; sybase_free_result($rs); sybase_close($link); ?>
<html> <body bgcolor=white> <?php $dbproc = sybase_connect("JDBC", "guest", "sybase"); if (!$dbproc) { return; } $res = sybase_query("select * from test", $dbproc); if (!$res) { return; } while ($arr = sybase_fetch_array($res)) { print $arr["i"] . " " . $arr["v"] . "<br>\n"; } ?> </body> </html>
$intention = $med[Intention]; $protocole = $med[Protocole]; $Tstage = $med[Code1]; $Nstage = $med[Code2]; $Mstage = $med[Code3]; $stage = $med[Code4]; $ptpn = $med[Code5]; //requete sur la partie CodeDiag $queryDIAG = "SELECT * FROM CodeDiag\n\t\t\tWHERE (CodeDiag.DiagCode='{$Diag}')"; $requeteDIAG = sybase_query($queryDIAG, $link); //while($co=sybase_fetch_array($requeteDIAG)) { $co = sybase_fetch_array($requeteDIAG); $DiagT = $co[1]; //requete sur la partie CodeRegion $queryREG = "SELECT * FROM CodeRegion\n\t\t\tWHERE (CodeRegion.RegionCode='{$Region}')"; $requeteREG = sybase_query($queryREG, $link); //while($re=sybase_fetch_array($requeteREG)) { $re = sybase_fetch_array($requeteREG); $RegT = $re[RegionText]; sybase_close($link); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" class="textprint" height="65"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20%"><img src="../images/UCL.jpg" width="70" height="105"></td> <td><p><b><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Université catholique de Louvain<br> </font></b> <font size="3"><b><font face="Verdana, Arial, Helvetica, sans-serif">Cliniques Universitaire Saint-Luc</font></b></font><br> <font size="1">association sans but lucratif</font></p>
/** * Get the flags for a field * * Currently supports: * + <samp>unique_key</samp> (unique index, unique check or primary_key) * + <samp>multiple_key</samp> (multi-key index) * * @param string $table the table name * @param string $column the field name * * @return string space delimited string of flags. Empty string if none. * * @access private */ function _sybase_field_flags($table, $column) { static $tableName = null; static $flags = array(); if ($table != $tableName) { $flags = array(); $tableName = $table; /* We're running sp_helpindex directly because it doesn't exist in * older versions of ASE -- unfortunately, we can't just use * DB::isError() because the user may be using callback error * handling. */ $res = @sybase_query("sp_helpindex {$table}", $this->connection); if ($res === false || $res === true) { // Fake a valid response for BC reasons. return ''; } while (($val = sybase_fetch_assoc($res)) !== false) { if (!isset($val['index_keys'])) { /* No useful information returned. Break and be done with * it, which preserves the pre-1.7.9 behaviour. */ break; } $keys = explode(', ', trim($val['index_keys'])); if (sizeof($keys) > 1) { foreach ($keys as $key) { $this->_add_flag($flags[$key], 'multiple_key'); } } if (strpos($val['index_description'], 'unique')) { foreach ($keys as $key) { $this->_add_flag($flags[$key], 'unique_key'); } } } sybase_free_result($res); } if (array_key_exists($column, $flags)) { return implode(' ', $flags[$column]); } return ''; }
function GetLastInsertID($sTable) { $res = sybase_query('SELECT @@identity', $this->conn); if ($res) { $Record = @sybase_fetch_array($res); sybase_free_result($res); return $Record[0]; } trigger_error('Could not retrieve @@identity of newly inserted record!!'); return -1; }
function simpleQuery($query) { $this->last_query = $query; $query = $this->modifyQuery($query); $result = @sybase_query($query, $this->connection); if (!$result) { return $this->raiseError(); } // Determine which queries that should return data, and which // should return an error code only. return DB::isManip($query) ? DB_OK : $result; }
/** * Send a query to Sybase and return the results as a Sybase resource * identifier. * * @param the SQL query * * @access public * * @return mixed returns a valid Sybase result for successful SELECT * queries, DB_OK for other successful queries. A DB error is * returned on failure. */ function simpleQuery($query) { $this->last_query = $query; $query = $this->modifyQuery($query); $result = @sybase_query($query, $this->connection); if (!$result) { return $this->sybaseRaiseError(); } if (is_resource($result)) { $numrows = $this->numRows($result); if (is_object($numrows)) { return $numrows; } $this->num_rows[$result] = $numrows; return $result; } // Determine which queries that should return data, and which // should return an error code only. return DB::isManip($query) ? DB_OK : $result; }
function currentid($seq_name) { $this->connect(); $currentid = 0; $q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name); $id = @sybase_query($q, $this->Link_ID); $res = @sybase_fetch_array($id); /* No current value, make one */ if (is_array($res)) { $currentid = $res["nextid"]; } return $currentid; }
/** * Get Patron Fines * * This is responsible for retrieving all fines by a specific patron. * * @param array $patron The patron array from patronLogin * * @throws \VuFind\Exception\Date * @throws ILSException * @return mixed Array of the patron's fines on success. */ public function getMyFines($patron) { $aid = $patron['address_id_nr']; $iln = $patron['iln']; //$lang = $patron['lang']; $sql = "select o.ppn" . ", r.costs_code" . ", r.costs" . ", rtrim(convert(char(20),r.date_of_issue,104))" . ", rtrim(convert(char(20),r.date_of_creation,104))" . ", 'Overdue' as fines" . ", o.shorttitle" . " from requisition r, ous_copy_cache o, volume v" . " where r.address_id_nr=" . $aid . "" . " and r.iln=" . $iln . " and r.id_number=v.volume_number" . " and v.epn=o.epn" . " and r.iln=o.iln" . " and r.costs_code in (1, 2, 3, 4, 8)" . " union select id_number" . ", r.costs_code" . ", r.costs" . ", rtrim(convert(char(20),r.date_of_issue,104))" . ", rtrim(convert(char(20),r.date_of_creation,104))" . ", r.extra_information" . ", '' as zero" . " from requisition r" . " where r.address_id_nr=" . $aid . "" . " and r.costs_code not in (1, 2, 3, 4, 8)" . ""; try { $result = []; $sqlStmt = sybase_query($sql); while ($row = sybase_fetch_row($sqlStmt)) { //$fine = $this->translate(('3'==$row[1])?'Overdue':'Dues'); $fine = $this->picaRecode($row[5]); $amount = null == $row[2] ? 0 : $row[2] * 100; //$balance = (null==$row[3])?0:$row[3]*100; $checkout = substr($row[3], 0, 12); $duedate = substr($row[4], 0, 12); $title = $this->picaRecode(substr($row[6], 0, 12)); $result[] = ['id' => $this->prfz($row[0]), 'amount' => $amount, 'balance' => $amount, 'checkout' => $checkout, 'duedate' => $duedate, 'fine' => $fine, 'title' => $title]; } return $result; } catch (\Exception $e) { throw new ILSException($e->getMessage()); } return []; }
/** * Sends a query to the database. * * This function sends a query to the database. * * @param string $query * @return mixed $result */ function query($query) { $this->sqllog .= pmf_debug($query); return sybase_query($query, $this->conn); }
function sql_query($query, $id) { global $dbtype; global $sql_debug; $sql_debug = 0; if ($sql_debug) { echo "SQL query: " . str_replace(",", ", ", $query) . "<BR>"; } switch ($dbtype) { case "MySQL": $res = @mysql_query($query, $id); return $res; break; case "mSQL": $res = @msql_query($query, $id); return $res; break; case "postgres": case "postgres_local": $res = pg_exec($id, $query); $result_set = new ResultSet(); $result_set->set_result($res); $result_set->set_total_rows(sql_num_rows($result_set)); $result_set->set_fetched_rows(0); return $result_set; break; case "ODBC": case "ODBC_Adabas": $res = @odbc_exec($id, $query); return $res; break; case "Interbase": $res = @ibase_query($id, $query); return $res; break; case "Sybase": $res = @sybase_query($query, $id); return $res; break; default: break; } }
/** * Execute the current query * @return resource */ protected function execute_query() { return @sybase_query($this->strQuery); }
/** * 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() * @since Method available since Release 1.6.0 */ function tableInfo($result, $mode = null) { if (is_string($result)) { /* * Probably received a table name. * Create a result resource identifier. */ if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) { return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED); } $id = @sybase_query("SELECT * FROM {$result} WHERE 1=0", $this->connection); $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->sybaseRaiseError(DB_ERROR_NEED_MORE_DATA); } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) { $case_func = 'strtolower'; } else { $case_func = 'strval'; } $count = @sybase_num_fields($id); $res = array(); if ($mode) { $res['num_fields'] = $count; } for ($i = 0; $i < $count; $i++) { $f = @sybase_fetch_field($id, $i); // column_source is often blank $res[$i] = array('table' => $got_string ? $case_func($result) : $case_func($f->column_source), 'name' => $case_func($f->name), 'type' => $f->type, 'len' => $f->max_length, 'flags' => ''); if ($res[$i]['table']) { $res[$i]['flags'] = $this->_sybase_field_flags($res[$i]['table'], $res[$i]['name']); } 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) { @sybase_free_result($id); } return $res; }
/** * Execute the query * * @access private called by the base class * @param string an SQL query * @return resource */ function _execute($sql) { $sql = $this->_prep_query($sql); return @sybase_query($sql, $this->conn_id); }
public function query($sql) { $this->result = sybase_query($sql, $this->link); }
function _query($sql, $inputarr = false) { global $ADODB_COUNTRECS; if ($ADODB_COUNTRECS == false && ADODB_PHPVER >= 0x4300) { return sybase_unbuffered_query($sql, $this->_connectionID); } else { return sybase_query($sql, $this->_connectionID); } }
/** * Executes given SQL statement. * * @param string $sql SQL statement * @return resource Result resource identifier * @access protected */ function _execute($sql) { return sybase_query($sql, $this->connection); }
function _query($sql, $inputarr) { //@sybase_free_result($this->_queryID); return sybase_query($sql, $this->_connectionID); }
function db_query($rlt) { global $base, $debug, $sql_query, $conn; $sql_query = $rlt; //echo $rlt; // if (strlen($debug) > 0) { echo '<HR>'.$rlt; } ////////////////////////////// PostGre if ($base == 'pgsql') { if (strlen($debug) > 0) { $xxx = pg_query($rlt) or die($rlt . pg_email_erro($rlt)); } else { $xxx = pg_query($rlt) or die('Erro de base <BR>' . pg_email_erro($rlt)); } } ////////////////////////////// MySQL if ($base == 'mysqlPDO') { $xxx = $conn->query($rlt); //if (strlen($debug) > 0) { $xxx = mysql_query($rlt) or die(mysql_error() . '<BR>'.$rlt); } //else { $xxx = mysql_query($rlt) or die('Erro de base'); } } if ($base == 'mysql') { if (strlen($debug) > 0) { $xxx = mysql_query($rlt) or die(mysql_error() . '<BR>' . $rlt); } else { $xxx = mysql_query($rlt) or die('Erro de base'); } } if ($base == 'mssql') { $rlt = sql_convert($rlt); $sql_query = $rlt; if (strlen($debug) > 0) { $xxx = mssql_query($rlt) or die(pg_error() . '<BR>' . $rlt); } else { $xxx = mssql_query($rlt); } } if ($base == 'sybase') { $xxx = sybase_query($rlt) or die(pg_error() . '<BR>' . $rlt); } return $xxx; }