예제 #1
0
파일: SQL.php 프로젝트: renq/ML-Lib
	/**
	 * 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
0
파일: PDOTest.php 프로젝트: renq/Simqel
 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
0
<?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
0
//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
0
 /**
  * @param array $columnsToSelect
  * @return array|null
  */
 public function oneAsArray($columnsToSelect = ['*'])
 {
     $this->limit(1);
     return $this->connection->fetch($this->getSelectQuery($columnsToSelect), $this->getBindingValues());
 }
예제 #6
0
 * @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 = "******" AND 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 = "******" AND user_password = "******"');
    if (mysql_num_rows($result) == 1) {
예제 #7
0
<?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>";