function select_to_table($query) { $results = mssql_query($query) or die("<li>errorno=" . mysql_errno() . "<li>error=" . mysql_error() . "<li>query=" . $query); $number_cols = mssql_num_fields($results); //display query echo "<b>query: {$query}</b>"; //layout table header echo "<table border = 1>\n"; echo "<tr align left>\n"; for ($i = 0; $i < $number_cols; $i++) { echo "<th>" . mssql_field_name($results, $i) . "</th>\n"; } echo "</tr>\n"; //end table header //layout table body while ($row = mssql_fetch_row($results)) { echo "<tr align left>\n"; for ($i = 0; $i < $number_cols; $i++) { echo "<td>"; if (!isset($row[$i])) { echo "NULL"; } else { echo $row[$i]; } echo "</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; }
public function get_web_log() { //select the database mssql_select_db($this->dbname, $this->dbcon); //SQL Select statement $xml = new XMLHandler(XML_DIR . "web_request_spk.xml"); $sql_from_xml = $xml->getNode("web_log"); $sqlselect = str_replace("FILTER_BY_PROGRAM", "", $sql_from_xml); //Run the SQL query $result = mssql_query($sqlselect); $numfields = mssql_num_fields($result); $string_result = ""; while ($row = mssql_fetch_row($result)) { $string_result .= "<tr>"; for ($i = 0; $i < $numfields; $i++) { if (mssql_field_name($result, $i) == "IP_ADDRESS") { $ip = explode(":", $row[$i]); $string_result .= "<td>" . $ip[0] . "</td>"; $string_result .= "<td>" . $ip[1] . "</td>"; } else { $string_result .= "<td>" . $row[$i] . "</td>"; } } $string_result .= "</tr>"; } return $string_result; }
function xcopy($mssql, $mysql, $db, $table, $sql) { $start = microtime(true); mysqli_select_db($mysql, $db); mssql_select_db($db, $mssql); $result = mssql_query($sql, $mssql, 20000); if ($result === false) { die("Error creating sync data\n"); } $s = 0; $r = mssql_num_rows($result); $name_count = mssql_num_fields($result); $name_list = ""; $update_list = ""; $value_list = ""; $sql = ""; $radix = 0; for ($i = 0; $i < $name_count; $i++) { $x = strtolower(mssql_field_name($result, $i)); $name_list .= "{$x},"; if ($x != "dex_row_id") { $update_list .= "{$x} = values({$x}),"; } } $name_list = rtrim($name_list, ","); $update_list = rtrim($update_list, ","); do { while ($row = mssql_fetch_row($result)) { for ($i = 0; $i < $name_count; $i++) { $value_list .= "'" . str_replace("'", "''", trim($row[$i])) . "',"; } $value_list = rtrim($value_list, ","); $radix++; $sql .= "\n({$value_list}),"; $value_list = ""; if ($radix > 2000) { $sql = trim($sql, ","); $sql = "insert into {$table} ({$name_list}) values {$sql} on duplicate key update {$update_list};"; $rset = mysqli_query($mysql, $sql); if ($rset === false) { die("Error inserting mysql data. \n" . mysqli_error($mysql) . "\n\n{$sql}\n\n"); } $radix = 0; $sql = ""; } $s++; } } while (mssql_fetch_batch($result)); if ($sql != "") { $sql = trim($sql, ","); $sql = "insert into {$table} ({$name_list}) values {$sql} on duplicate key update {$update_list};"; $rset = mysqli_query($mysql, $sql); if ($rset === false) { die("Error inserting mysql data. \n" . mysqli_error($mysql) . "\n\n{$sql}\n\n"); } } $end = microtime(true); $total = $end - $start; echo "imported {$db}.{$table} [ {$s} ] records in {$total} sec.\n"; }
public function GetMembname() { global $tpl; $SQL_Q = $this->query("SELECT memb_name FROM MEMB_INFO WHERE memb___id = '" . $_SESSION['Login'] . "'"); $SQL = mssql_fetch_row($SQL_Q); $tpl->set("memb_name", (string) $SQL[0]); }
public function GetDatabases() { $collection = array(); $result = mssql_query("select name from sys.databases"); while ($row = mssql_fetch_row($result)) { $collection[] = $row[0]; } return $collection; }
function getOneColumnAsArray() { $column = array(); $queryId = $this->connection->execute($this->getSQL()); while (is_array($row = mssql_fetch_row($queryId))) { $column[] = is_numeric($row[0]) ? $row[0] : mb_convert_encoding($row[0], 'UTF-8', 'Windows-1251'); } mssql_free_result($queryId); return $column; }
public function getLastId() { $last_id = false; $resource = mssql_query("SELECT @@identity AS id", $this->link); if ($row = mssql_fetch_row($resource)) { $last_id = trim($row[0]); } mssql_free_result($resource); return $last_id; }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * @param resource $d The datasource resource */ function mssqlAdapter($d) { parent::RecordSetAdapter($d); $fieldcount = mssql_num_fields($d); // grab the number of fields $ob = ""; $be = $this->isBigEndian; $fc = pack('N', $fieldcount); if (mssql_num_rows($d) > 0) { mssql_data_seek($d, 0); while ($line = mssql_fetch_row($d)) { // write all of the array elements $ob .= "\n" . $fc; foreach ($line as $value) { // write all of the array elements if (is_string($value)) { // type as string $os = $this->_directCharsetHandler->transliterate($value); //string flag, string length, and string $len = strlen($os); if ($len < 65536) { $ob .= "" . pack('n', $len) . $os; } else { $ob .= "\f" . pack('N', $len) . $os; } } elseif (is_float($value) || is_int($value)) { // type as double $b = pack('d', $value); // pack the bytes if ($be) { // if we are a big-endian processor $r = strrev($b); } else { // add the bytes to the output $r = $b; } $ob .= "" . $r; } elseif (is_bool($value)) { //type as bool $ob .= ""; $ob .= pack('c', $value); } elseif (is_null($value)) { // null $ob .= ""; } } } } $this->serializedData = $ob; for ($i = 0; $i < $fieldcount; $i++) { // loop over all of the fields $this->columnNames[] = $this->_directCharsetHandler->transliterate(mssql_field_name($d, $i)); } $this->numRows = mssql_num_rows($d); }
function loadTables() { if ($this->isExisting && !$this->isTablesLoaded) { $queryId = $this->connection->execute("select TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_CATALOG='" . $this->name . "'"); while (is_array($row = mssql_fetch_row($queryId))) { $this->tables[$row[0]] = null; } mssql_free_result($queryId); $this->isTablesLoaded = true; } }
public function Valid_UserPwd() { if (empty($this->password) == true) { exit(Print_error("Senha", 3)); } $checkQ = $this->query('exec dbo.webVerifyLogin "' . $this->login . '","' . $this->password . '","' . HASHMD5 . '"'); $check = mssql_fetch_row($checkQ); if ($check[0] == 0) { exit(Print_error("Usuário ou Senha incorretos.")); } }
public function lastInsertId($name = '') { $sql = $name ? 'SELECT IDENT_CURRENT(' . $this->quote($name) . ')' : 'SELECT @@IDENTITY'; if ($result = mssql_query($sql, $this->link)) { $row = mssql_fetch_row($result); if ($row[0] === null) { return -1; } return $row[0]; } return false; }
public static function query($queryStr = '', $objectStr = '') { $queryDB = mssql_query(self::$dbConnect, $queryStr); if (preg_match('/insert into/i', $queryDB)) { mssql_next_result($queryDB); $row = mssql_fetch_row($queryDB); self::$insertID = $row[0]; } if (is_object($objectStr)) { $objectStr($queryDB); } return $queryDB; }
public function GetSerial() { if (defined("WZ_GETITEMSERIAL") == false) { $SQL_Q = $this->query("exec WZ_GetItemSerial"); } else { $SQL_Q = $this->query("exec " . constant("WZ_GETITEMSERIAL")); } $SQL = mssql_fetch_row($SQL_Q); $Serial = strtoupper(dechex($SQL[0])); $Serial = str_pad($Serial, 8, 0, STR_PAD_LEFT); $this->Item_Serial = $Serial; return $Serial; }
public static function charIDsByUsername($szUsername) { $result = array(); core::$sql->changeDB("shard"); $nJID = core::$sql->getRow("select JID from _AccountJID where AccountID='{$szUsername}'"); $hQuery = mssql_query("select CharID from _User where UserJID='{$nJID}'"); $i = 0; while ($row = mssql_fetch_row($hQuery)) { $result[$i] = $row[0]; $i++; } return $result; }
public function _fetch_row() { switch ($this->type) { case 'mssql': return mssql_fetch_row($this->result); break; case 'sqlsrv': return sqlsrv_fetch_array($this->result, SQLSRV_FETCH_NUMERIC); break; default: case 'mysql': return mysql_fetch_row($this->result); break; } }
/** * @throws SQLException * @return void */ protected function initTables() { include_once 'creole/drivers/mssql/metadata/MSSQLTableInfo.php'; $dsn = $this->conn->getDSN(); if (!@mssql_select_db($this->dbname, $this->dblink)) { throw new SQLException('No database selected'); } $result = mssql_query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'", $this->dblink); if (!$result) { throw new SQLException("Could not list tables", mssql_get_last_message()); } while ($row = mssql_fetch_row($result)) { $this->tables[strtoupper($row[0])] = new MSSQLTableInfo($this, $row[0]); } }
function tmssql() { print "<h3>mssql</h3>"; $db = mssql_connect('JAGUAR\\vsdotnet', 'adodb', 'natsoft') or die('No Connection'); mssql_select_db('northwind', $db); $rs = mssql_query('select getdate() as date', $db); $o = mssql_fetch_row($rs); print_r($o); mssql_free_result($rs); print "<p>Delete</p>"; flush(); $rs2 = mssql_query('delete from adoxyz', $db); $p = mssql_num_rows($rs2); mssql_free_result($rs2); }
public function __construct() { global $ODBC, $LD_Items; $_GET['ProductID'] = (int) $_GET['ProductID']; $SQL_Q = $this->query("SELECT ConnectStat FROM MEMB_STAT WHERE memb___id='" . $_SESSION['Login'] . "'"); $SQL = mssql_fetch_object($SQL_Q); if ($SQL->ConnectStat != 0) { exit(Print_error("<ul><li>Você deve estar offline do jogo para efetuar essa ação!</li></ul>")); } $searchKitQ = $ODBC->query("SELECT priceFix FROM Kits WHERE active = 1 AND Number = " . $_GET['ProductID']); if (odbc_num_rows($searchKitQ) == 0) { exit(Print_error("<script type=\"text/javascript\">alert(\"Erro kit não cadastrado.\"); window.location='?';</script>")); } $searchItensKitQ = $ODBC->query("SELECT * FROM KitsItemsDetails WHERE kitNumber = " . $_GET['ProductID']); echo "<ul><li>Aguarde em quanto sua compra é processada.</li><br />"; //Inicio Função independente para cobrar o kit $searchKit = odbc_fetch_object($searchKitQ); $SQL_Q = $this->query("SELECT " . GOLDCOLUMN . " FROM " . GOLDTABLE . " WHERE " . GOLDMEMBIDENT . " = '" . $_SESSION['Login'] . "'"); $SQL_R = mssql_fetch_row($SQL_Q); if ($SQL_R[0] < $searchKit->priceFix) { exit(Print_error("<ul><li>Desculpe, essa compra não pode ser realizada, pois seu saldo de " . GOLDNAME . " é insuficiente.</li></ul>")); } $SQL_Q = $this->query("UPDATE " . GOLDTABLE . " SET " . GOLDCOLUMN . " = " . GOLDCOLUMN . "-" . $searchKit->priceFix . " WHERE " . GOLDMEMBIDENT . " = '" . $_SESSION['Login'] . "' AND " . GOLDCOLUMN . " >= " . $searchKit->priceFix . "; select @@rowcount as rows;"); $SQL_R = mssql_fetch_object($SQL_Q); if ((int) $SQL_R->rows == 0) { exit(Print_error("<ul><li>Erro ao cobrar pelo kit.</li></ul>")); } //Fim Função independente para cobrar o kit $ODBC->query("UPDATE Kits SET solds=solds+1 WHERE Number=" . $_GET['ProductID']); $searchLastSoldNumberQ = $ODBC->query("SELECT max(Number) as Numb FROM LogSoldsKits"); $searchLastSoldNumber = odbc_fetch_object($searchLastSoldNumberQ); $searchLastSoldNumber->Numb = (int) $searchLastSoldNumber->Numb + 1; $ODBC->query("INSERT INTO LogSoldsKits (login,kitNumber,price,data) VALUES ('{$_SESSION['Login']}', {$_GET['ProductID']}, {$searchKit->priceFix}, '" . time() . "')"); require "sockets.lib.php"; //exit(var_dump($socketLib)); while ($searchItensKit = odbc_fetch_object($searchItensKitQ)) { //var_dump($searchItensKit); $LD_FinishBuy = new LD_FinishBuy($searchItensKit->itemNumber, $searchItensKit->fixLVL, $searchItensKit->fixOP, $searchItensKit->fixANC, $searchItensKit->fixSkill == 0 ? "false" : "true", $searchItensKit->fixLuck == 0 ? "false" : "true", $searchItensKit->fixOpEx1 == 0 ? "false" : "true", $searchItensKit->fixOpEx2 == 0 ? "false" : "true", $searchItensKit->fixOpEx3 == 0 ? "false" : "true", $searchItensKit->fixOpEx4 == 0 ? "false" : "true", $searchItensKit->fixOpEx5 == 0 ? "false" : "true", $searchItensKit->fixOpEx6 == 0 ? "false" : "true", $searchItensKit->fixJH, $searchItensKit->fixRefine == 0 ? "false" : "true", $searchItensKit->fixSocket1 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket2 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket3 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket4 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket5 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket1, $searchItensKit->fixSocket2, $searchItensKit->fixSocket3, $searchItensKit->fixSocket4, $searchItensKit->fixSocket5, true); $ODBC->query("INSERT INTO LogSoldsKitsDetails (NumberSoldKit,login,itemId,itemSerial) VALUES ({$searchLastSoldNumber->Numb}, '{$_SESSION['Login']}', '{$searchItensKit->itemNumber}', '{$LD_Items->Item_Serial}')"); if ($LD_FinishBuy->delivered == true) { echo "<li>Item: <strong>{$LD_FinishBuy->NAME}</strong>, entregue.</li>"; } else { echo "<li>Item: <strong>{$LD_FinishBuy->NAME}</strong>, não houve espaço. <br />Libere espaço no bau e reenvie o item pelo histórico de compras.</li>"; } unset($LD_FinishBuy); } echo "<br /><li>Compra finalizada com sucesso!</li></ul>"; }
public static function getInspector($hostname, $userid, $password) { $connection = mssql_connect($hostname, $userid, $password); if ($connection != false) { $result = mssql_query("select @@version"); $row = mssql_fetch_row($result); if (stripos($row[0], "Microsoft SQL Server 2005") !== false) { return new MSSQLInspector2005($hostname, $userid, $password); } else { return new MSSQLInspector($hostname, $userid, $password); } mssql_close($connection); } else { throw new Exception("Unable to connect to server"); } }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * @param resource $d The datasource resource */ function mssqlAdapter($d) { parent::RecordSetAdapter($d); $fieldcount = mssql_num_fields($d); // grab the number of fields for ($i = 0; $i < $fieldcount; $i++) { // loop over all of the fields $this->columnNames[] = mssql_field_name($d, $i); } if (mssql_num_rows($d) > 0) { mssql_data_seek($d, 0); while ($line = mssql_fetch_row($d)) { $this->rows[] = $line; } } }
public function __construct($facebookid = 0) { // A. TODO: Get the access_token and token_secret from the database //$access_token = '61344b1a-0e88-4ccc-8854-cc6219d83642'; //$token_secret = '7e01bf18-cc44-4332-b40e-dc4ae501098a'; $db = new DB_Access(); $results = $db->GetAuthTokenByUserID($facebookid); $row = mssql_fetch_row($results); $access_token = $row[2]; $token_secret = $row[3]; // B. Create a OAuthAPIClient object and initialize it $this->apiConsumer = new OAuthAPIClient(AppConfig::$f1_base_url, AppConfig::$f1_default_church_code, AppConfig::$f1_key, AppConfig::$f1_secret); $this->apiConsumer->setPathsFromConfig(); // This is important. Set the access_token and the token_secret from step A $this->apiConsumer->init_AccessToken($access_token, $token_secret); $this->baseUrl = $this->apiConsumer->getBaseUrl(); }
function fetch() { global $row, $databaseType; if ($databaseType == "mysql") { @($row = mysql_fetch_row($this->index)); if (mysql_errno() != 0) { echo "<font color='red'><b>" . mysql_error() . "</b></font><br/>"; } } if ($databaseType == "postgresql") { $row = pg_fetch_row($this->index); } if ($databaseType == "sqlserver") { $row = mssql_fetch_row($this->index); } return $row; }
static function checkForTable($name) { $sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES"; @($result = mssql_query($sql)); $_SESSION["messages"]->addMessage("executing MSSQL: {$sql}"); if ($result) { while ($row = mssql_fetch_row($result)) { if (strtolower($row[2]) == strtolower($name)) { return true; } } } if ($result) { mssql_free_result($result); } return false; }
function MoveNext() { if (!$this->EOF) { $this->_currentRow++; if ($this->fetchMode & ADODB_FETCH_ASSOC) { global $ADODB_mssql_has_datetimeconvert; if ($ADODB_mssql_has_datetimeconvert) { // only for PHP 4.2.0 or later $this->fields = @mssql_fetch_assoc($this->_queryID); } else { $flds = @mssql_fetch_array($this->_queryID); if (is_array($flds)) { $fassoc = array(); foreach ($flds as $k => $v) { if (is_numeric($k)) { continue; } $fassoc[$k] = $v; } $this->fields = $fassoc; } else { $this->fields = $flds; } } if (ADODB_ASSOC_CASE == 0) { foreach ($this->fields as $k => $v) { $this->fields[strtolower($k)] = $v; } } else { if (ADODB_ASSOC_CASE == 1) { foreach ($this->fields as $k => $v) { $this->fields[strtoupper($k)] = $v; } } } } else { $this->fields = @mssql_fetch_row($this->_queryID); } if (is_array($this->fields)) { return true; } $this->EOF = true; } return false; }
/** * Constructs a new MssqlResultSet. * * \param $sql * The sql query to execute. * \param $backend * A reference to the used backend. */ function MssqlResultSet($sql, &$backend) { assert('is_string($sql)'); $this->sql = $sql; $this->backend =& $backend; // Attention! Due to a bug in the mssql driver, when you use insert or // update, mssql_query() always returns false, so that error checking is // effectively impossible. $this->rs = mssql_query($sql, $this->backend->id); if (!ANEWT_DATABASE_MSSQL_ROWS_AFFECTED_EXISTS) { // For update/insert/delete queries, figure out the number of rows affected $kw = strtolower(substr(trim($sql), 0, 6)); if ($kw == "delete" || $kw == "insert" || $kw == "update") { $rs = mssql_query("SELECT @@ROWCOUNT", $this->backend->id); list($this->rowcount) = mssql_fetch_row($rs); } else { $this->rowcount = 0; } } }
public function get_unit_rfs() { //select the database mssql_select_db($this->dbname, $this->dbcon); //SQL Select statement $xml = new XMLHandler(XML_DIR . "web_request_spk.xml"); $sql_from_xml = $xml->getNode("rfs"); $sqlselect = str_replace("FILTER_BY_PROGRAM", "", $sql_from_xml); //Run the SQL query $result = mssql_query($sqlselect); $numfields = mssql_num_fields($result); $string_result = ""; while ($row = mssql_fetch_row($result)) { $string_result .= "<tr>"; for ($i = 0; $i < $numfields; $i++) { $string_result .= "<td>" . $row[$i] . "</td>"; } $string_result .= "</tr>"; } return $string_result; }
/** * Get a row from the RecordSet. * * Case $row is set, return that row, case else, return the next row. * * @param int $row Row to return, defaults to next. * @param int $type Type of array to return (RS_ROW_NUM | RS_ROW_ASSOC | RS_ROW_BOTH). * @return array Returns the row from the RecordSet, or FALSE if EOF. */ function Row($row = -1, $type = RS_ROW_ASSOC) { if ($row != -1) { if (!mssql_data_seek($this->result, $row)) { return FALSE; } $this->row = $row; } $this->row++; switch ($type) { case RS_ROW_NUM: return mssql_fetch_row($this->result); break; case RS_ROW_ASSOC: return mssql_fetch_assoc($this->result); break; case RS_ROW_BOTH: return mssql_fetch_array($this->result); break; } return FALSE; }
/** * Gets the DBMS' native error code produced by the last query * * @return int the DBMS' error code */ function errorNative() { $res = @mssql_query('select @@ERROR as ErrorCode', $this->connection); if (!$res) { return DB_ERROR; } $row = @mssql_fetch_row($res); return $row[0]; }
/** * 单列数据和集合查询 * @param string $sql 要执行查询的SQL语句参数请用"?"代替 * @param array $pam 数字下标的数组,数组项依次替换SQL中的"?"参数 * @return array 某一数据字段结果集合 */ function one_column_array($sql, $pam = null) { $query = $this->base_query($sql, $pam); $res = array(); while ($tn = mssql_fetch_row($query)) { $res[] = $tn[0]; } if (count($res) > 0) { return $res; } return null; }
function _fetch($ignore_fields = false) { if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_NUM) { //ADODB_FETCH_BOTH mode $this->fields = @mssql_fetch_array($this->_queryID); } else { if ($this->hasFetchAssoc) { // only for PHP 4.2.0 or later $this->fields = @mssql_fetch_assoc($this->_queryID); } else { $this->fields = @mssql_fetch_array($this->_queryID); if (@is_array(${$this}->fields)) { $fassoc = array(); foreach (${$this}->fields as $k => $v) { if (is_integer($k)) { continue; } $fassoc[$k] = $v; } $this->fields = $fassoc; } } } if (!$this->fields) { } else { if (ADODB_ASSOC_CASE == 0) { foreach ($this->fields as $k => $v) { $this->fields[strtolower($k)] = $v; } } else { if (ADODB_ASSOC_CASE == 1) { foreach ($this->fields as $k => $v) { $this->fields[strtoupper($k)] = $v; } } } } } else { $this->fields = @mssql_fetch_row($this->_queryID); } return $this->fields; }