TheyWorkForYou

Query
in package
implements IteratorAggregate, ArrayAccess

Database Query

Represents a single query to the database.

After a SELECT

$q can be used as an iterator with foreach to loop over the rows. $q->first() returns the first row if present, else null. $q->exists() returns a boolean as to whether there were any results. $q->rows() returns the number of rows selected $q->insert_id() returns NULL. $q->affected_rows() returns NULL.

After an INSERT

$q->rows() returns NULL. $q->insert_id() returns the last_insert_id (if there's AUTO_INCREMENT on a column). $q->affected_rows() returns 1.

After an UPDATE

If rows have been changed: $q->rows() returns NULL. $q->insert_id() returns 0. $q->affected_rows() returns the number of rows changed.

After a DELETE

$q->rows() returns NULL. $q->insert_id() returns 0. $q->affected_rows() returns the number of rows changed.

Table of Contents

Interfaces

IteratorAggregate
ArrayAccess

Properties

$affected_rows  : mixed
$data  : mixed
$insert_id  : mixed
$rows  : mixed
$success  : mixed

Methods

__construct()  : mixed
affected_rows()  : mixed
displayResult()  : mixed
error()  : mixed
exists()  : mixed
fetchAll()  : mixed
field()  : mixed
first()  : mixed
getIterator()  : mixed
insert_id()  : mixed
offsetExists()  : mixed
offsetGet()  : mixed
offsetSet()  : mixed
offsetUnset()  : mixed
query()  : mixed
row()  : mixed
rows()  : mixed
success()  : mixed

Properties

$affected_rows

private mixed $affected_rows = null

$data

private mixed $data = array()

$insert_id

private mixed $insert_id = null

$rows

private mixed $rows = null

$success

private mixed $success = true

Methods

__construct()

public __construct(mixed $conn) : mixed
Parameters
$conn : mixed

affected_rows()

public affected_rows() : mixed

displayResult()

public displayResult() : mixed

error()

public error(string $errormsg) : mixed
Parameters
$errormsg : string

exists()

public exists() : mixed

fetchAll()

public fetchAll() : mixed

field()

public field(int $row_index, string $column_name) : mixed
Parameters
$row_index : int
$column_name : string

first()

public first() : mixed

getIterator()

public getIterator() : mixed

insert_id()

public insert_id() : mixed

offsetExists()

public offsetExists(mixed $offset) : mixed
Parameters
$offset : mixed

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed

offsetSet()

public offsetSet(mixed $offset, mixed $value) : mixed
Parameters
$offset : mixed
$value : mixed

offsetUnset()

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed

query()

public query([mixed $sql = "" ][, mixed $params = null ]) : mixed
Parameters
$sql : mixed = ""
$params : mixed = null

row()

public row(int $row_index) : mixed
Parameters
$row_index : int

rows()

public rows() : mixed

success()

public success() : mixed

        
On this page

Search results