本文整理汇总了PHP中Query::numRows方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::numRows方法的具体用法?PHP Query::numRows怎么用?PHP Query::numRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::numRows方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Query
<?php
include "Query.php";
$username = $_POST["uname"];
$password = $_POST["pwd"];
$q = new Query("SELECT * FROM player WHERE uname='{$username}' AND password='{$password}';");
$q->execute();
//$result = $q->getResult();
$count = $q->numRows();
//echo $username;
//echo $password;
//echo $count;
if ($count == 1) {
//session_register("username");
//session_register("password");
// Update online bit status if login success
$q = new Query("UPDATE player SET online=1");
$q->execute();
header("location:login_success.php?uname=" . $username);
} else {
header("location:login_failure.php");
}
示例2: Query
<?php
$uname = $_GET["uname"];
include "../lib/Query.php";
$counter = new Query("Select * FROM statistics");
$counter->execute();
$userTotal = $counter->numRows();
$leaderboardLimit = 10;
if ($userTotal < $leaderboardLimit) {
$leaderboardLimit = $userTotal;
}
$query = new Query("Select * FROM statistics ORDER BY points DESC, wins DESC, uname ASC LIMIT {$leaderboardLimit}");
$query->execute();
$query->getResult();
echo '<html>
<body>
<h3>Hello ' . $uname . ', this is the Leaderboard page. </h3>
<table border="1">
<tr>
<td>Ranking</td>
<td>Username</td>
<td>Wins</td>
<td>Losses</td>
<td>Ties</td>
<td>Total Games</td>
<td>Points</td>
</tr>';
for ($i = 0; $i < $leaderboardLimit; $i++) {
$row = $query->getRow($i);
$username = $row[0];
$wins = $row[1];
示例3: Query
//check to see if user was placed by another request
$query = new Query("SELECT * FROM player WHERE ingame = 2 AND uname='{$uname}';");
$query->execute();
if ($query->numRows() == 1) {
//get the gstate table and send it back
$query = new Query("SELECT opponent FROM player WHERE uname='{$uname}';");
$query->execute();
$row = $query->getRow(0);
$opponent = stripslashes($row[0]);
echo $opponent . '_gstate';
exit;
}
}
//if we didnt find anything reply accordingly
//and reset ingame=0
if ($query->numRows() == 0) {
$query = new Query("UPDATE player SET ingame=0 WHERE uname='{$uname}';");
$query->execute();
echo 0;
exit;
}
$row = $query->getRow(0);
$opponent = stripslashes($row[0]);
//match the two players
$query = new Query("UPDATE player SET opponent='{$opponent}' WHERE uname='{$uname}';");
$query->execute();
$query = new Query("UPDATE player SET opponent='{$uname}' WHERE uname='{$opponent}';");
$query->execute();
//set the two players ingame status to ingame
$query = new Query("UPDATE player SET ingame=2 WHERE uname='{$uname}' OR uname='{$opponent}';");
$query->execute();
示例4: Query
<?php
/*pollMove_2.php created by Tim Bouvier 11/26/2013
Checks gamestate and returns a json
object with gamestate.*/
include '../lib/Query.php';
$winning_game = "";
$req_uname = $_GET["uname"];
$tbl = $_GET["tbl"];
$query = new Query("SELECT * FROM " . $tbl . ";");
//execute it and convert it to json eventually
$query->execute();
//initialize gamestate array
for ($i = 0; $i < $query->numRows(); $i++) {
$row = $query->getRow($i);
$coordinates[$i] = stripslashes($row[1]);
}
if ($coordinates[0] == $coordinates[1] && $coordinates[1] == $coordinates[2] && $coordinates[1] != "") {
$winning_game = $coordinates[1];
}
if ($coordinates[3] == $coordinates[4] && $coordinates[4] == $coordinates[5] && $coordinates[4] != "") {
$winning_game = $coordinates[4];
}
if ($coordinates[6] == $coordinates[7] && $coordinates[7] == $coordinates[8] && $coordinates[7] != "") {
$winning_game = $coordinates[7];
}
if ($coordinates[0] == $coordinates[3] && $coordinates[3] == $coordinates[6] && $coordinates[3] != "") {
$winning_game = $coordinates[3];
}
if ($coordinates[1] == $coordinates[4] && $coordinates[4] == $coordinates[7] && $coordinates[4] != "") {
$winning_game = $coordinates[4];
示例5: Query
<?php
/* makeMove_2.php created by Tim Bouvier on 11/27/2013
accepts client requests to make a move on the board
and validates or denies them.
*/
include "../lib/Query.php";
$uname = $_GET["uname"];
$coordinate = $_GET["coordinate"];
$tbl = $_GET["tbl"];
$ret = 0;
//check if its their turn
$turn = new Query("SELECT * FROM player WHERE uname='{$uname}' AND turn=1;");
$turn->execute();
if ($turn->numRows() == 0) {
echo 0;
exit;
}
//check if spot is valid
$query = new Query("SELECT uname FROM " . $tbl . " WHERE coordinate={$coordinate};");
$query->execute();
$row = $query->getRow(0);
$res = stripslashes($row[0]);
if ($res == "") {
//valid so now update the spot to the requesting user
$update_row = new Query("UPDATE " . $tbl . " SET uname='{$uname}' WHERE coordinate={$coordinate};");
$update_row->execute();
//set their turn to inactive
$turn_inactive = new Query("UPDATE player SET turn=0 WHERE uname='{$uname}';");
$turn_inactive->execute();
//get opponents uname
示例6: reset
/**
* Reset the last query to the first result
*
* This needs to be used if the query has been 'looped through'
* until the end and you wish to loop through again
* @access public
*/
public function reset()
{
$this->check();
if (Query::numRows($this->last_query)) {
mysql_data_seek($this->last_query, 0);
$this->internal_pointer = 0;
}
}