public function query($sql, $start = null, $perpage = null, $nolimit = false) { $start and !$perpage and $perpage = 10000; $query = mssql_query($sql, $this->dbConnection()); if ($start) { $qcount = mssql_num_rows($query); if ($qcount < $start) { return array(); } else { mssql_data_seek($query, $start); } } if ($query) { $result = array(); while ($row = mssql_fetch_assoc($query)) { if (DBCHARSET == 'gbk' && CHARSET != 'gbk') { $row = Base_Class::gbktoutf($row); } $result[] = $row; if ($perpage && count($result) >= $perpage) { break; } } return $result; } else { $this->halt("数据库查询错误", $sql); } }
private function executeQuery() { $return = false; if ($this->queryType == 'other') { if (mssql_query($this->query, $this->link) === true) { $return = true; $this->error = mssql_get_last_message(); } } else { if ($result = mssql_query($this->query, $this->link)) { // Conteo de registros if ($this->queryType == 'insert' || $this->queryType == 'update' || $this->queryType == 'delete') { $this->numRows = mssql_rows_affected($this->link); $return = true; } else { $this->numRows = mssql_num_rows($result); $fetchType = MSSQL_NUM; if ($this->queryReturn == 'assoc') { $fetchType = MSSQL_ASSOC; } elseif ($this->queryReturn == 'both') { $fetchType = MSSQL_BOTH; } $return = array(); while ($row = mssql_fetch_array($result, $fetchType)) { array_push($return, $row); } } $this->error = mssql_get_last_message(); mssql_free_result($result); } else { $this->error = mssql_get_last_message(); } } return $return; }
/** * @param $sql * * @return array */ public function query($sql) { // $this->connection = $this->getConnection(); // Run query $query = mssql_query($sql, $this->connection); // On error if ($query === false) { Response::error(500, $_SERVER["SERVER_PROTOCOL"] . ' DB query failed (SQL): ' . mssql_get_last_message()); } // E.g. boolean is returned if no rows (e.g. no resource found or on UPDATE) if ($query === true) { $response = $query; } else { // Response $response = array(); // // Loop rows and add to response array if (mssql_num_rows($query) > 0) { while ($row = mssql_fetch_assoc($query)) { $response[] = $row; } } // Free the query result mssql_free_result($query); } // Close link $this->closeConnection(); // return $response; }
public function __construct($account) { try { global $ldMssql; $this->clearVars(); $checkVault = $ldMssql->query("SELECT [DbVersion] FROM [" . DATABASE_ACCOUNTS . "].[dbo].[warehouse] WHERE [AccountId] = '" . $account . "'"); if (mssql_num_rows($checkVault) == 0) { throw new Exception("<script> alert('Essa conta não possui baú.'); location = '?page=paneluser'; </script>"); } $dbVersion = mssql_fetch_object($checkVault); if (is_numeric($dbVersion->DbVersion) == false) { throw new Exception("Vault class error: dbVersion must be numeric."); } if ($dbVersion < 1 || $dbVersion->DbVersion > 3) { throw new Exception("Vault class error: dbVersion invalid."); } $this->dbVersion = $dbVersion->DbVersion; $this->account = $account; if ($this->dbVersion == 3) { $getLenghts = $ldMssql->query("USE [" . DATABASE_ACCOUNTS . "]; SELECT [length] FROM [syscolumns] WHERE OBJECT_NAME([id]) = 'warehouse' AND [name] = 'Items'; USE [" . DATABASE . "];"); $getLenghts = mssql_fetch_object($getLenghts); $this->slotNumbers = $getLenghts->length * 2 / 32; } } catch (Exception $msg) { exit($msg->getMessage()); } }
/** * mengambil record dari sebuah tabel dalam bentuk array * @param sqlString ini sql string * @param offset * */ public function getRecord($sqlString, $offset = 1) { // echo $sqlString; if (mssql_num_rows($result = $this->query($sqlString)) >= 1) { if ($offset == '') { $offset = 1; } $ft = $this->getFieldTable("field"); // print_r($ft); $countFieldTable = count($ft); $counter = 1; while ($row = mssql_fetch_array($result)) { //echo $row . "<br>"; $tempRecord['no'] = $offset; for ($i = 0; $i < $countFieldTable; $i++) { $tempRecord[$ft[$i]] = trim($row[$ft[$i]]); } $ListRecord[$counter] = $tempRecord; $counter++; $offset++; } // print_r($ListRecord); $this->ListRecord = $ListRecord; } else { $this->ListRecord = array(); } return $this->ListRecord; }
function dbquery_func_old($connection_info, $query, $debug = "off") { if ($connection_info['db_type'] == "mysql") { mysql_connect($connection_info['db_host'] . ":" . $connection_info['db_port'], $connection_info['username'], $connection_info['password']) or die("Unable to connect to " . $connection_info['db_host']); mysql_select_db($connection_info['db_name']) or die("Unable to select database " . $connection_info['db_name']); $return = mysql_query($query); if ($debug == "on") { $merror = mysql_error(); if (!empty($merror)) { print "MySQL Error:<br />" . $merror . "<p />Query<br />: " . $query . "<br />"; } print "Number of rows returned: " . mysql_num_rows($return) . "<br />"; } } else { if ($connection_info['db_type'] == "mssql") { mssql_connect($connection_info['db_host'] . "," . $connection_info['db_port'], $connection_info['username'], $connection_info['password']) or die("Unable to connect to " . $connection_info['db_host'] . "<br />" . $query); mssql_select_db($connection_info['db_name']) or die("Unable to select database " . $connection_info['db_name']); $return = mssql_query($query); if ($debug == "on") { $merror = mssql_get_last_message(); if (!empty($merror)) { print "MySQL Error: " . $merror . "<br />Query" . $query . "<br />"; } print "Number of rows returned: " . mssql_num_rows($result) . "<br />"; } } } return $return; }
public function __construct($BuyID, $searchItem = false) { global $LD_Items; $this->searchItem = $searchItem; $SQL_Q = $this->query("SELECT ConnectStat, DATEDIFF(MI, DisConnectTM, getdate()) DisConnectTM FROM MEMB_STAT WHERE memb___id='" . $_SESSION['Login'] . "'"); if (mssql_num_rows($SQL_Q) == 0) { exit("<ul><li>Você deve entrar no jogo ao menos uma vez para efetuar esta ação!</li></ul>"); } $SQL = mssql_fetch_object($SQL_Q); if ($SQL->ConnectStat != 0) { exit("<ul><li>Você deve estar offline do jogo para efetuar esta ação!</li></ul>"); } $this->BuyID = $BuyID; $this->VerifyBuy(); $this->FindItem(); if ($this->searchItem == true) { exit; } if ((int) RECOVERY_LIMIT_ITEM > 0 && $this->recovery >= (int) RECOVERY_LIMIT_ITEM) { exit(Print_error("<ul><li>Erro, excedido o número de vezes que o item ser recuperado (" . RECOVERY_LIMIT_ITEM . " vezes).</li></ul>")); } $this->Find_Details(); $LD_Items->Write_Variables($this->ProductID, $this->TP, $this->ID, $this->ProductSerial, $this->DUR, $this->X, $this->Y, $this->Item_Level, $this->Item_Option, $this->Item_Ancient, $this->Item_Skill, $this->Item_Luck, $this->Item_OpExc_1, $this->Item_OpExc_2, $this->Item_OpExc_3, $this->Item_OpExc_4, $this->Item_OpExc_5, $this->Item_OpExc_6, $this->Item_JH, $this->Item_Refine, $this->Item_Socket_Slot_1, $this->Item_Socket_Slot_2, $this->Item_Socket_Slot_3, $this->Item_Socket_Slot_4, $this->Item_Socket_Slot_5, $this->Item_Socket_Slot_1_Option, $this->Item_Socket_Slot_2_Option, $this->Item_Socket_Slot_3_Option, $this->Item_Socket_Slot_4_Option, $this->Item_Socket_Slot_5_Option); $LD_Items->GenerateHex(); $LD_Items->GetVaultContent(); $LD_Items->CutSlotsVault(); $LD_Items->CutHexSlotsVault(); $LD_Items->RestructureSlotsFree(); $LD_Items->FindSlotsFree(); $this->WriteLog(); $LD_Items->WriteVault(); print "<ul><li>Seu item foi recuperado com sucesso! Obrigado.</li></ul>"; }
function login($email, $password) { /* query db and set session variables, as necessary */ $theQuery = "SELECT * FROM users WHERE email = '" . $email . "' AND userpassword = '******'"; $theData = queryG0($theQuery); if (!mssql_num_rows($theData)) { echo 'No records found'; } else { while ($row = mssql_fetch_array($query)) { $thisEmail = $row['username']; $thisPassword = $row['userpassword']; $thisID = $row['id']; $thisAccessLevel = $row['accesslevel']; } if ($email == $thisEmail && $password == $thisPassword) { createSessionVariables($thisID, $thisAccessLevel); /* Redirect to admin landing page */ header("Location: " . $GLOBALS['adminLandingPage']); } else { clearSessionVariables(); /* Redirect to login with error msg */ header("Location: " . $GLOBALS['loginWithError']); } } }
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"; }
private function queryContainsNewUsers($query) { if ($query == false) { return false; } return mssql_num_rows($query) > 0 ? true : false; }
function findFlights($flight) { //Connects to database require 'connect_db.php'; $query = mssql_query('SELECT * FROM FLIGHT'); if (!mssql_num_rows($query)) { echo 'No records found'; } else { //Creates tables and fills it with flight numbers and their delays echo '<br><br><br><br><table border = 1>'; echo '<th>Flight Number</th><th>Delayed</th><th>Depature Time</th>'; while ($row = mssql_fetch_assoc($query)) { $i = 0; //Check if flight is what is looking for if (strcmp($row['Flight_number'], $flight) == 0) { $i = $i + 1; echo '<tr><td>' . $row['Flight_number'] . '</td>'; if (strcmp($row['Delayed'], '1') != 0) { echo '<td>' . 'On Time' . '</td>'; } else { echo '<td>' . 'Delayed' . '</td>'; } echo '<td>' . $row['Depature_time'] . '</td></tr>'; //^End else } } //^ends while echo '</table>'; } }
function count() { // Attention! See notes above. if ($this->rs === true) { return 0; } return mssql_num_rows($this->rs); }
function numRows($r = 0) { if (!$r) { $r = $this->lastResult; } $cnt = mssql_num_rows($r); return $cnt; }
public static function num_rows($queryDB = '', $objectStr = '') { $numRows = mssql_num_rows($queryDB); if (is_object($objectStr)) { $objectStr($numRows); } return $numRows; }
public function loginCookies($id, $hash) { $queryCookies = "SELECT id, hash FROM [user] WHERE id={$id} AND hash='{$hash}'"; if (mssql_num_rows(mssql_query($queryCookies)) == 1) { $userEntry = mssql_fetch_array(mssql_query($queryCookies)); setcookie("id", $userEntry['id'], time() + 60 * 60 * 24, "/"); setcookie("hash", $userEntry['hash'], time() + 60 * 60 * 24, "/"); return true; } }
/** * 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); }
/** * Go to a row int the RecordSet. * * @param int $row Row to go to. * @return bool Returns TRUE on success, FALSE if failed. */ function SetRow($row = 0) { if (!mssql_num_rows($this->result)) { return FALSE; } if (!mssql_data_seek($this->result, $row)) { return FALSE; } $this->row = $row; return TRUE; }
public function count() { //print_r($this); $lastresult = $this->results[$this->lasthash]; //print_r($this->results); $count = mssql_num_rows($lastresult); if (!$count) { $count = 0; } return $count; }
public function Valid_UserName() { if (empty($this->login) == true) { exit(Print_error("Usuário", 3)); } $Temp_Q = $this->query("SELECT memb___id FROM MEMB_INFO WHERE memb___id='" . (string) $this->login . "'"); $Temp = mssql_num_rows($Temp_Q); if ($Temp == 0) { exit(Print_error(" incorreto.")); } }
function traerNombrePlanAlim($cod_pa) { $sql = "SELECT nombre FROM palimt WHERE codigo = '" . $cod_pa . "';"; $res = mssql_query($sql); if (mssql_num_rows($res) > 0) { $row = mssql_fetch_array($res); return $row["nombre"]; } else { return ""; } }
public function getNamaBulanById($id) { $sql = 'SELECT Bulan FROM ' . $this->table . ' WHERE BulanId=' . $id; $result = mssql_query($sql); if (mssql_num_rows($result) > 0) { while ($val = mssql_fetch_assoc($result)) { $namaBulan = $val['Bulan']; } } mssql_free_result($result); return $bulan; }
function my_num_rows($result) { global $conf_db_type; switch ($conf_db_type) { case 'mysql': return @mysql_num_rows($result); break; case 'mssql': return @mssql_num_rows($result); break; } }
public function getRwByKelurahan($id) { $sql = 'SELECT * FROM ' . $this->table . ' WHERE KelurahanId=' . $id; $result = mssql_query($sql); $data = array(); if (mssql_num_rows($result) > 0) { while ($val = mssql_fetch_assoc($result)) { $data[] = array('RWId' => $val['RWId'], 'Nama' => $val['Nama'], 'KelurahanId' => $val['KelurahanId']); } } mssql_free_result($result); return $data; }
public function getKecamatanByKelurahan($id) { $sql = 'SELECT a.Nama, a.KecamatanId, a.KodeDepdagri FROM ' . $this->table . ' a INNER JOIN M_Kelurahan b on a.KecamatanId=b.KecamatanId WHERE b.KelurahanId=' . $id; $result = mssql_query($sql); $data = array(); if (mssql_num_rows($result) > 0) { while ($val = mssql_fetch_assoc($result)) { $data[] = array('KecamatanId' => $val['KecamatanId'], 'Nama' => $val['Nama'], 'KodeDedagri' => $val['KodeDepdagri']); } } mssql_free_result($result); return $data; }
public function getAllRecord() { $sql = 'SELECT * FROM ' . $this->table . ' ORDER BY TempatPelayananKBId'; $result = mssql_query($sql); $data = array(); if (mssql_num_rows($result) > 0) { while ($val = mssql_fetch_assoc($result)) { $data[] = array('TempatPelayananKBId' => $val['TempatPelayananKBId'], 'Nama' => $val['Nama']); } } mssql_free_result($result); return $data; }
/** * Checa se o usuário esta logado, e retorna um objecto com o numero do previlegio dele caso esteja logado. */ public function checkLogin() { global $ldMssql; if (!isset($_SESSION['LOGIN']) && empty($_SESSION['LOGIN'])) { return false; } $checkPrevilegy = $ldMssql->query("SELECT previlegy FROM dbo.webPrevilegy WHERE username='******'LOGIN'] . "'"); if (mssql_num_rows($checkPrevilegy) == 0) { return (int) 0; } else { return mssql_fetch_object($checkPrevilegy); } }
/** * Metodo que ejecuta el query que tiene el objeto. * */ public function FNCQueryEjecutar($piBandera = -1) { if ($piBandera != -1) { echo "'a'" . $this->sQuery . "'a'"; } try { $this->rsQuery = mssql_query($this->sQuery); $this->iTotalRegs = mssql_num_rows($this->rsQuery); } catch (Exception $e) { echo $this->sQuery; } $this->FNCQueryArregloAgregar(); }
public function getAlasanTidakKbById($id) { $sql = 'SELECT * FROM ' . $this->table . ' WHERE ID=' . $id; $result = mssql_query($sql); $data = array(); if (mssql_num_rows($result) > 0) { while ($val = mssql_fetch_assoc($result)) { $data[] = array('ID' => $val['ID'], 'Alasan' => $val['Alasan'], 'SortNumber' => $val['SortNumber'], 'IsActive' => $val['IsActive']); } } mssql_free_result($result); return $data; }
public function consultaDadosUsuario($matricula) { $matricula = addslashes($matricula); $this->conecta(); $SQL = "SELECT * FROM dbo.pessoa WHERE cod_pessoa_aux = '{$matricula}'"; $res = mssql_query($SQL, $this->getConmssql()); // return $res; if (mssql_num_rows($res) > 0) { $user = mssql_fetch_object($res); return $user; } else { return false; } }
public function GetVaultContent() { $getLenghts = $this->query("SELECT [length] FROM [syscolumns] WHERE OBJECT_NAME([id]) = 'warehouse' AND [name] = 'Items';"); $getLenghts = mssql_fetch_object($getLenghts); $this->Varbinary = $getLenghts->length; $this->LineCounts = $getLenghts->length * 2 / (constant("SYSTEM_DBVERSION") == 1 ? 20 : 32) / 8; $this->SlotCounts = $getLenghts->length * 2 / (constant("SYSTEM_DBVERSION") == 1 ? 20 : 32); $SQL_Q = $this->query("SELECT 1 FROM warehouse WHERE Accountid='" . $_SESSION['Login'] . "'"); if (mssql_num_rows($SQL_Q) == 0) { $this->query("INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion, pw) VALUES ('" . $_SESSION['Login'] . "', 0x" . str_pad("", $this->Varbinary * 2, "F") . ", 0, GetDate(), " . constant("SYSTEM_DBVERSION") . ", 0);"); } $SQL_Q = $this->query("DECLARE @vault varbinary(" . $this->Varbinary . "); SELECT @vault = items FROM warehouse WHERE AccountID='" . $_SESSION['Login'] . "' " . (constant("ENCGAMES_S6") === true ? " AND VaultID = 1" : NULL) . "; PRINT @vault;"); $this->Vault_Content = substr(mssql_get_last_message($SQL_Q), 2); }