本文整理汇总了PHP中Connection::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::fetch方法的具体用法?PHP Connection::fetch怎么用?PHP Connection::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::fetch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Returns rows from database.
* @param string $query
* @param array $params
* @param int $limit
* @param int $offset
* @return array
*/
public function get($query, array $params = array(), $limit = false, $offset = 0) {
if ($limit) {
$query = $this->strategy->limit($query, $limit, $offset);
}
$return = array();
$result = $this->connection->query($query, $params);
if ($result) {
while ($row = $this->connection->fetch($result)) {
$return[] = $row;
}
}
return $return;
}
示例2: testFetchEOF
public function testFetchEOF()
{
$this->createTable();
$statement = $this->connection->query("SELECT * FROM cat");
$this->connection->fetch($statement);
// Simon's Cat
$this->connection->fetch($statement);
// Garfield
$this->assertFalse($this->connection->fetch($statement));
}
示例3: mysql_num_rows
<?php
include 'db_connect.php';
//include the db_connect.php file
//Create and set a new connection
$get = new Connection("db1");
//"db1" is user defined in db_connect.php
//Create a query: $var->query("SQL_STATEMENT"); $var is the variable you created a connection with.
$selectusers = $get->query("SELECT * FROM users");
//Do whatever you would like with the query
echo mysql_num_rows($selectusers);
//Use built in functions to make one line queries.
echo $get->fetch($selectusers);
//fetch() fetches the associated rows. More quick functions coming soon.
示例4: getFullDate
//Declaring $sameDate as an array.
if ($db->numRows($result) < 1) {
//Checking if the result is smaller then 1.
echo '<li class="day">';
echo "<h4>" . getFullDate($date) . "<a href=\"#\" onClick=\"nextDate('{$date}')\" class=\"todoNav\">Next</a><a href=\"#\" onClick=\"previousDate('{$date}')\" class=\"todoNav\">Previous </a> </h4>";
//Returns the date as a String.
echo '<fieldset>';
echo '<input class="ToDoInsert" type="text" value="Insert your ToDo here and hit the enter-key." name="ToDoInsert" />';
echo '</fieldset>';
echo '<ul>';
echo '</ul>';
echo '</li>';
//End Of This Day.
} else {
//Displaying the result.
while ($row = $db->fetch($result)) {
if (!in_array($row['todo_date'], $sameDate)) {
echo '<li class="day">';
echo "<h4>" . getFullDate($date) . "<a href=\"#\" onClick=\"nextDate('{$date}')\" class=\"todoNav\">Next</a><a href=\"#\" onClick=\"previousDate('{$date}')\" class=\"todoNav\">Previous </a> </h4>";
//Returns the date as a String.
echo '<fieldset>';
echo '<input class="ToDoInsert" type="text" value="Insert your ToDo here and hit the enter-key." name="ToDoInsert" />';
echo '</fieldset>';
echo '<ul>';
$resultList = $db->query('SELECT * FROM th_todo WHERE todo_userId = ' . $_SESSION['user']['id'] . ' AND `todo_date` = "' . $row['todo_date'] . '"');
while ($rowWhile = $db->fetch($resultList)) {
echo '<li>';
//Resetting the $done var.
$done = '';
if ($rowWhile['todo_done'] == 1) {
$done = 'done';
示例5: oneAsArray
/**
* @param array $columnsToSelect
* @return array|null
*/
public function oneAsArray($columnsToSelect = ['*'])
{
$this->limit(1);
return $this->connection->fetch($this->getSelectQuery($columnsToSelect), $this->getBindingValues());
}
示例6: Connection
* @version 0.2
* @description Threads Login File
* @author Joeri Hermans
* @contact joeri.her@gmail.com
* @license GNU
*/
require_once '../system/config.php';
require_once '../system/rewrite.php';
require_once '../system/classes.php';
$db = new Connection();
if (!empty($_SESSION['user']['username']) && !empty($_SESSION['user']['password'])) {
$result = $db->query('SELECT * FROM th_users WHERE user_username = "' . $_SESSION['user']['username'] . '" AND user_password = "' . $_SESSION['user']['password'] . '"');
//Retrieving result from MySQL
if (mysql_num_rows($result) == 1) {
//If MySQL returns 1 row.
while ($row = $db->fetch($result)) {
//You spin my head round baby round round.
$_SESSION['user']['id'] = $row['user_id'];
//Fetching User Id.
$_SESSION['user']['name'] = $row['user_name'];
//Fetching User Name.
$_SESSION['user']['lastName'] = $row['user_lastName'];
//Fetching User Lastname.
$_SESSION['user']['perm'] = $row['user_permission'];
//Fetching the users' permission.
}
}
}
if (isset($_POST['username'])) {
$result = $db->query('SELECT * FROM th_users WHERE user_username = "' . $_POST['username'] . '" AND user_password = "' . md5($_POST['password']) . '"');
if (mysql_num_rows($result) == 1) {
示例7: mysql_num_rows
<?php
include 'db_connect.php';
//include the db_connect.php file
print "<HTML><BODY><H1>Showing the users of the sampledb that has been created in the RDS few seconds ago!</H1>\n";
//Create and set a new connection
$get = new Connection("db1");
//"db1" is user defined in db_connect.php
//Create a query: $var->query("SQL_STATEMENT"); $var is the variable you created a connection with.
$selectusers = $get->query("SELECT * FROM users");
//Do whatever you would like with the query
print "Total Number of user records: ";
print mysql_num_rows($selectusers);
print "\n\r";
//Use built in functions to make one line queries.
$rowarray = $get->fetch($selectusers);
//fetch() fetches the associated rows.
print "<table>\n\r";
foreach ($rowarray as $row) {
print "<tr>\n\r";
foreach ($row as $col) {
print "\t<td>{$col}</td>\n\r";
}
print "</tr>\n\r";
}
print "</table></BODY></HTML>";