本文整理汇总了PHP中Query::getRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::getRow方法的具体用法?PHP Query::getRow怎么用?PHP Query::getRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::getRow方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create(array $data = null)
{
$class = ucfirst($this->model);
if ($data) {
$obj = new $class();
foreach ($data as $key => $value) {
$obj->{$key} = $value;
}
$this->errors = $obj->complaints;
$obj->save();
$this->onCreate($obj);
$id = Database::getLastId();
$result = new Query($this->model, $id);
$this->setRedirect("show/{$id}", ucfirst($this->model + " created."));
}
if ($result) {
return $result->getRow(1);
}
}
示例2: Query
<?php
// Created on Nov 14 2013 by Ian Santagata
// Version 1.0
// Checks to see if the game has been won/tied and if the game is over
//
// Returns 1 if game is over and returns 0 if game is not over
include "../lib/Query.php";
// Pull all of the coordinate and username data from the table
$q = new Query("SELECT * FROM gstate");
$q->execute();
$spot0 = $q->getRow(0);
$spot1 = $q->getRow(1);
$spot2 = $q->getRow(2);
$spot3 = $q->getRow(3);
$spot4 = $q->getRow(4);
$spot5 = $q->getRow(5);
$spot6 = $q->getRow(6);
$spot7 = $q->getRow(7);
$spot8 = $q->getRow(8);
// Test for winning conditions based on upper left spot
switch ($spot0[1]) {
case $username:
// If upper three spots owned by same user
switch ($spot1[1]) {
case $username:
switch ($spot2[1]) {
case $username:
return 1;
}
break;
示例3:
$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];
$losses = $row[2];
$ties = $row[3];
$played = $row[4];
$points = $row[5];
$ranking = $i + 1;
echo '
<tr>
<td>' . $ranking . '</td>
<td>' . $username . '</td>
<td>' . $wins . '</td>
<td>' . $losses . '</td>
<td>' . $ties . '</td>
<td>' . $played . '</td>
示例4: Query
<?php
// Created by Ian Santagata
// Test script to test MySQL PHP interaction
// Feel free to edit and test for your own needs
include "Query.php";
$q = new Query("SELECT * FROM gstate");
$q->execute();
$result = $q->getResult();
for ($i = 0; $i <= 8; $i++) {
$row = $q->getRow($i);
printf("Coordinate: %s Username: %s\n", $row[0], $row[1]);
}
示例5: Query
<?php
// Created on Nov 15 2013 by Ian Santagata
// Version 1.0
// Logs a player out via the database fields
include "Query.php";
// Get target username from XMLHttpRequest sent by JS
$uname = $_GET["uname"];
// Search database for the username
$q = new Query("SELECT * FROM player WHERE uname='{$uname}'");
$q->execute();
$result = $q->getResult();
// If the user exists and is logged in, log him out
if ($row = $q->getRow(0)) {
if ($row[2] == '1') {
$query = new Query("UPDATE player SET online=b'0' WHERE uname='{$uname}'");
$query->execute();
}
}
echo '<html>
<body>
<h1>You are logged out, ' . $uname . '</h1>
<br><a href="../index.html">Return to Login Screen</a>
</body>
</html>';
示例6: Query
<?php
/*addWin.php created by Ian Santagata on 12/4/2013
updates database table to reflect win/loss/tie/played/points
user records
*/
include "../lib/Query.php";
$uname = $_GET["uname"];
// extract winning user data from table
$query = new Query("SELECT uname,wins,played,points FROM statistics WHERE uname='{$uname}';");
$query->execute();
//$query->getResult();
$row = $query->getRow(0);
// increase values as necessary (+3 points for a win)
$wins = $row[1] + 1;
$played = $row[2] + 1;
$points = $row[3] + 3;
// update winning player data
$query = new Query("UPDATE statistics SET wins={$wins}, played={$played}, points={$points} WHERE uname='{$uname}';");
$query->execute();
// success message
echo "successfully updated statistics";
示例7: findOne
public static function findOne($model, $criteria)
{
$results = new Query($model, $criteria, 1);
return $results->getRow(0);
}
示例8: Query
<?php
// Created on Nov 15 2013 by Ian Santagata
// Version 1.0
// Poll for game state change with player turn control, return board for moves/owners
include "../lib/Query.php";
$username = $_GET("uname");
$state = "";
$turn = 0;
// Wait for turn of player with loop
do {
$q = new Query("SELECT turn FROM player WHERE uname='{$username}'");
$q->execute();
$result = $q->getResult();
if ($row = $q->getRow()) {
$turn = $row[0];
}
// Wait five seconds
sleep(5);
} while ($turn != 1);
// Continue when it is the player's turn
$query = new Query("SELECT * FROM gstate");
$query->execute();
$res = $query->getResult();
// Setup the state to be returned to JS
for ($i = 0; $i <= 8; $i++) {
$rows = ${$query}->getRow($i);
$state = $state . "{$rows['0']}|";
if ($rows[1] == NULL) {
$state = $state . "null|";
} else {
示例9: Query
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
$opp = new Query("SELECT opponent FROM player WHERE uname='{$uname}';");
$opp->execute();
$row = $opp->getRow(0);
$name = stripslashes($row[0]);
//set opponent to active
$opp_set_active = new Query("UPDATE player SET turn=1 WHERE uname='{$name}';");
$opp_set_active->execute();
} else {
//not a valid move
echo 0;
exit;
}
//success
echo 1;