本文整理汇总了PHP中sqlsrv_has_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlsrv_has_rows函数的具体用法?PHP sqlsrv_has_rows怎么用?PHP sqlsrv_has_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlsrv_has_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkUserSession
public function checkUserSession()
{
if (!isset($this->SessionID)) {
return array(false, "Session key empty");
}
$SessionID = $this->SessionID;
$sql = "SELECT Email FROM Sessions WHERE SessionID = ?";
$params = array($SessionID);
global $conn;
if ($conn) {
$stmt = sqlsrv_query($conn, $sql, $params);
if ($stmt === false) {
return array(false, "Connection to server failed.");
} else {
if (sqlsrv_has_rows($stmt) > 0) {
$email = '';
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
$email = $row['Email'];
}
return array(true, $email);
} else {
return array(false, "Failed to authenticate");
}
}
}
}
示例2: dumpFounderData
/**
* Dumps the Founder data into a table
*
* @param int $CompanyID
*/
function dumpFounderData($CompanyID)
{
// include the data access class
include_once "DAO.php";
try {
// create a new data access object
$db = new DAO();
$sql = "EXEC dbo.GetFounderByCompanyID @CompanyID = " . $CompanyID;
// set the select statement
$db->setSQL($sql);
// execute the SQL
if ($db->execute()) {
// did we get some rows
if (sqlsrv_has_rows($db->getResultSet())) {
// output the table and the first row (column headers)
echo '<br>';
echo '<table class="sorted table-autosort:0 table-stripeclass:alternate">';
echo "<thead><tr>";
echo "<th class='table-sortable:default' width='100'>Name</th>";
echo "</tr></thead><tbody>";
// output the table rows
while ($row = sqlsrv_fetch_array($db->getResultSet(), SQLSRV_FETCH_ASSOC)) {
echo '<tr><td class="left" width="70"><a href="../Participant/History.php?wfID=' . $row['ID'] . '" target="_blank">' . $row['FounderName'] . '</a></td></tr>';
}
// finish the table
echo "</tbody></table>";
} else {
echo "<div class='err'>No data found.</div>";
}
}
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
echo "</br>";
}
示例3: query
/**
* Execute Query to obtain one or more objects from the NECLIMS db; returns string on error
*
* @param $sql
* @param optional class specification
*/
function query($sql, $object = NULL)
{
// include object class if specifed
if ($object != NULL) {
require_once $object . ".cls.php";
}
// create a data access object
$dao = new DAO();
// pass the sql statement to the data access object
$dao->setSQL($sql);
// declare an array for storing the row results
$retVal = array();
try {
// run the sql statement
if ($dao->execute() && sqlsrv_has_rows($dao->getResultSet())) {
// object specified.
if ($object != NULL) {
// while there were more results/rows, save the object in the array
while ($row = sqlsrv_fetch_object($dao->getResultSet(), $object . "")) {
$retVal[] = $row;
}
} else {
// while there were more results/rows, save the object in the array
while ($row = sqlsrv_fetch_array($dao->getResultSet(), SQLSRV_FETCH_ASSOC)) {
$retVal[] = $row;
}
}
}
} catch (Exception $e) {
return "Query Error: " . $e->getMessage() . ". SQL: " . $sql . ". Object specified: " . $object;
}
// return to the caller
return $retVal;
//error_log(print_r($retVal, true));
}
示例4: existeTabla
/**
*
* @param resource $conn
* Recurso que contiene la conexión SQL.
* @param string $tabla
* @param boolean $comprobar
* Si está a true (valor por defecto) siempre hace la comprobación.
* Si se pone el valor a false sólo hace la comprobación cuando es
* día 1.
* @return mixed array si hay un error SQL. Si la tabla no existe false. Si la
* tabla existe true.
*/
function existeTabla($conn, $tabla, $comprobarTabla = 1)
{
$hoy = getdate();
if ($hoy["mday"] == 1 or $comprobarTabla) {
global $respError;
$sql = "select * from dbo.sysobjects where id = object_id(N'{$tabla}')";
// Ejecutar una consulta SQL para saber si existe la tabla de auditoría
//////////////////////////////////////////////////////
$stmt = sqlsrv_query($conn, $sql);
if ($stmt === false) {
if (($errors = sqlsrv_errors()) != null) {
$SQLSTATE = $errors[0]["SQLSTATE"];
$Cerror = $errors[0]["code"];
$Merror = utf8_encode($errors[0]["message"]);
if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
if (DEBUG & DEBUG_ERROR_SQL) {
$mensaje = "--[" . date("c") . "] código: {$Cerror} mensaje: {$Merror} \n";
$mensaje .= "--Error en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
error_log($mensaje . $sql . "\r\n", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
}
}
// Error al hacer la consulta
return $respError->errorSQL($SQLSTATE, $Cerror, $Merror);
}
}
if (sqlsrv_has_rows($stmt) === false) {
// La tabla no existe.
return false;
}
}
// La tabla existe o no hay que comprobarlo
return true;
}
示例5: hasRows
public static function hasRows($connection, $query, $params = NULL)
{
if (!$params) {
$query = sqlsrv_has_rows(sqlsrv_query($connection, $query));
} else {
$query = sqlsrv_has_rows(sqlsrv_query($connection, $query, $params));
}
return $query;
}
示例6: create_env_devices
function create_env_devices($conn)
{
$query_check_data_exists = "SELECT * FROM riot4.ENV_settings";
$statement_check_data_exist = sqlsrv_query($conn, $query_check_data_exists);
if (!sqlsrv_has_rows($statement_check_data_exist)) {
$MID = DEFAULT_ENV_ID;
$query_insert_devices = "INSERT INTO riot4.ENV_settings (id,Device,Value) VALUES (?,'light_bulb',4),(?,'fan_table',8),(?,'light_table',2)";
$params = array($MID, $MID, $MID);
sqlsrv_query($conn, $query_insert_devices, $params);
}
}
示例7: getPlayerID
function getPlayerID($gameName, $clanID)
{
$db = new BaseDB();
$records = $db->dbQuery("SELECT PlayerID from Player WHERE GameName = '{$gameName}' AND ClanID = {$clanID}");
if (sqlsrv_has_rows($records)) {
$record = sqlsrv_fetch_array($records, SQLSRV_FETCH_BOTH);
return $record['PlayerID'];
} else {
return null;
}
}
示例8: fetch_rows
private function fetch_rows()
{
$num_rows = $this->num_rows();
if ($num_rows > 0 && sqlsrv_has_rows($this->result)) {
for ($i = 0; $i < $num_rows; $i++) {
$result_array[$i] = sqlsrv_fetch_array($this->result, SQLSRV_FETCH_ASSOC);
}
//END for
return $result_array;
} else {
return null;
}
//END if
}
示例9: checkPW
function checkPW($user, $password)
{
$conn = sqlsrv_connect($GLOBALS['srvname'], $GLOBALS['con_info']);
$query = "SELECT * FROM Gamer WHERE username=? AND password=?";
$params = array($user, $password);
$result = sqlsrv_query($conn, $query, $params);
if (!$result) {
die(print_r(sqlsrv_errors()));
}
$numrows = sqlsrv_has_rows($result);
if (!$numrows) {
return false;
}
sqlsrv_close($conn);
return true;
}
示例10: tekenProduct
function tekenProduct($productNaam, $image, $beschrijving, $resterendeTijd, $productNummer)
{
if ($resterendeTijd == '0:0:0:0') {
$sql99 = "update Voorwerp set VeilingGesloten='Ja' where Voorwerpnummer = " . $productNummer . "";
$stmt99 = sqlsrv_query($conn, $sql99);
$uitvoer99 = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
$where = "WHERE Voorwerpnummer = " . $productNummer . "";
$sql = 'select V.Titel, V.Verkoper
from Voorwerp V
' . $where . '';
$stmt = sqlsrv_query($conn, $sql);
$uitvoer = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
$sql2 = 'select Gebruikersnaam, Voornaam, Achternaam, Mailbox
from Gebruiker
where Gebruikersnaam=(select top 1 B.Gebruiker
from Voorwerp V INNER JOIN Bod B
ON V.Voorwerpnummer=B.Voorwerp
' . $where . '
ORDER BY B.Bodbedrag DESC)';
$stmt2 = sqlsrv_query($conn, $sql2);
$rows = sqlsrv_has_rows($stmt2);
if ($rows == true) {
$row = sqlsrv_fetch_array($stmt2, SQLSRV_FETCH_ASSOC);
$email = $row['Mailbox'];
$msg = "Gefeliciteerd! U heeft de veiling met de naam: " . rtrim($uitvoer['Titel']) . " gewonnen! \n Wanneer u uw product ontvangen hebt kunt u feedback achterlaten op de verkoper met deze link: iproject12.icasites.nl/feedbackAchterlaten.php?voorwerp=" . $productNummer . "&gebruiker=" . $uitvoer['Verkoper'] . "\n Bewaar deze email goed.";
mail($email, "Gewonnen veiling", $msg);
}
if ($rows == false) {
$sql2 = "select Mailbox\n\t\t\t\t\t\t\tfrom Gebruiker\n\t\t\t\t\t\t\twhere Gebruikersnaam='" . $uitvoer['Verkoper'] . "'";
$stmt2 = sqlsrv_query($conn, $sql2);
$row = sqlsrv_fetch_array($stmt2, SQLSRV_FETCH_ASSOC);
$email = $row['Mailbox'];
$msg = "Helaas! uw veiling met de naam: " . rtrim($uitvoer['Titel']) . " heeft geen biedingen gekregen. \n Uw veiling is gesloten.";
mail($email, "Uw veiling is gesloten", $msg);
}
}
$class = "product";
echo '<div class="' . $class . '">
<img src="resources/images/' . $image . '" alt="' . $image . '">
<h1>' . $productNaam . '</h1>
<div class="productoverzicht">
' . $beschrijving . '
</div>
<h4>' . $resterendeTijd . '</h4>
<a href="productDetailPagina.php?id=' . $productNummer . '">Bekijk veiling </a>
</div>';
}
示例11: ENV_logged_on
function ENV_logged_on()
{
$query = "SELECT * FROM riot4.ENV WHERE id = ?";
$params = array($_SESSION['MID']);
$statement = sqlsrv_query($conn, $query, $params);
if (sqlsrv_has_rows($statement)) {
$row = sqlsrv_fetch_array($statement);
if ($row['OTP'] == $_SESSION['ENV_OTP']) {
$_SESSION['ENV_OTP'] = $row['OTP'];
} else {
$_SESSION['ENV_OTP'] = NULL;
$_SESSION['MID'] = NULL;
$_SESSION['ROOT'] = NULL;
}
}
return isset($_SESSION['MID']);
}
示例12: dumpParticipantWorkFlows
function dumpParticipantWorkFlows($DONOR_CODE)
{
// include the data access class
include_once "DAO.php";
try {
// create a new data access object
$db = new DAO();
// set the SQL
$sql = "EXEC dbo.GetParticipantWorkFlows @DONOR_CODE ='" . $DONOR_CODE . "'";
// set the select statement
$db->setSQL($sql);
// execute the SQL
if ($db->execute()) {
// did we get some rows
if (sqlsrv_has_rows($db->getResultSet())) {
// output the table and the first row (column headers)
echo '<br>';
echo '<table class="sorted table-autosort:0 table-stripeclass:alternate">';
echo "<thead><tr>";
echo "<th class='table-sortable:default' width='70'>Name</th>";
echo "<th class='table-sortable:default' width='295'>Description</th>";
echo "<th class='table-sortable:default' width='75'>Status</th>";
echo "<th class='table-sortable:default' width='150'>Next step</th>";
echo "<th class='table-sortable:default' width='200'>Next step role</th>";
echo "</tr></thead><tbody>";
// output the table rows
while ($row = sqlsrv_fetch_array($db->getResultSet(), SQLSRV_FETCH_ASSOC)) {
echo '<tr><td class="left" width="70"><a href="../Participant/History.php?wfID=' . $row['ID'] . '" target="_blank">' . $row['Name'] . '</a></td>';
echo '<td class="left" width="295">' . $row['Description'] . '</td>';
echo '<td class="center" width="75">' . $row['WorkFlowStatus'] . '</td>';
echo '<td class="left" width="150">' . $row['NextStep'] . '</td>';
echo '<td class="left" width="200">' . $row['Role'] . '</td></tr>';
}
// finish the table
echo "</tbody></table>";
} else {
echo "<div class='err'>No data found.</div>";
}
}
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
echo "</br>";
}
示例13: doLogin
function doLogin($params)
{
$lquery = "SELECT username, rank, class, race FROM Gamer WHERE username=? AND password=?";
$srvname = "localhost";
$con_info = array("Database" => "EPGP", "UID" => "sa", "PWD" => "cakepie");
$conn = sqlsrv_connect($srvname, $con_info);
if (!$conn) {
die(print_r(sqlsrv_errors(), true));
}
if (isset($conn) && isset($lquery)) {
$result = sqlsrv_query($conn, $lquery, $params);
} else {
echo "DB Query missing connection or query";
}
if (sqlsrv_has_rows($result)) {
return sqlsrv_fetch_array($result);
} else {
return false;
}
}
示例14: signUp
function signUp()
{
if (!empty($_POST['username'])) {
$checkUser = $_POST['username'];
unset($query);
$query = "select * from users where username = '{$checkUser}'";
$stmt = sqlsrv_query($GLOBALS['conn'], $query);
$record = sqlsrv_has_rows($stmt);
if (!$record) {
$this->regUser();
} else {
//echo "Sorry! You are already registered.";
sqlsrv_close($GLOBALS['conn']);
die(print_r(sqlsrv_errors(), true));
}
}
if (isset($_POST['submit'])) {
echo "Submit call";
signUp();
}
}
示例15: while
while ($row = sqlsrv_fetch_array($statement)) {
$query_env_update = "UPDATE riot4.ENV_settings SET Value = ? WHERE id = ? AND Device = ?";
$params = array($row['Value'], $Envir_ID, $row['Device']);
$statement_env_update = sqlsrv_query($conn, $query_env_update, $params);
}
}
$msg = "You are admin for the environment";
header("Location: /env_settings.php?Message=" . urlencode($msg));
} else {
if (get_count($_SESSION['MID']) == 0) {
/* Change ENV values to that of first user
-------------------------------------------*/
$query = "SELECT * from riot4.settings WHERE User_ID = ?";
$params = array($_SESSION['userid']);
$statement = sqlsrv_query($conn, $query, $params);
if (sqlsrv_has_rows($statement)) {
while ($row = sqlsrv_fetch_array($statement)) {
$query_env_update = "UPDATE riot4.ENV_settings SET Value = ? WHERE id = ? AND Device = ? AND LOCK=0";
$params = array($row['Value'], $Envir_ID, $row['Device']);
$statement_env_update = sqlsrv_query($conn, $query_env_update, $params);
}
}
$msg = "You are 1st user in the environment";
header("Location: /env_settings.php?Message=" . urlencode($msg));
}
}
} else {
$msg = "Environment_ID/OTP combination is incorrect.<br><br>";
$valid = TRUE;
}
} else {