Dotclear 2.24
Loading...
Searching...
No Matches
record Class Reference

Query Result Record Class. More...

Inheritance diagram for record:
staticRecord extStaticRecord

Public Member Functions

 __construct ($result, array $info)
 
 toStatic ()
 
 __call (string $f, $args)
 
 __get ($n)
 
 f ($n)
 
 field ($n)
 
 exists ($n)
 
 __isset (string $n)
 
 extend (string $class)
 
 extensions ()
 
 index (?int $row=null)
 
 fetch ()
 
 moveStart ()
 
 moveEnd ()
 
 moveNext ()
 
 movePrev ()
 
 isEnd ()
 
 isStart ()
 
 isEmpty ()
 
 count ()
 
 columns ()
 
 rows ()
 
 row ()
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Protected Member Functions

 getData ()
 

Protected Attributes

 $__link
 
 $__result
 
 $__info
 
 $__extend = []
 
 $__index = 0
 
 $__row = false
 

Detailed Description

Query Result Record Class.

This class acts as an iterator over database query result. It does not fetch all results on instantiation and thus, depending on database engine, should not fill PHP process memory.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $result,
array  $info 
)

Constructor

Creates class instance from result link and some informations. $info is an array with the following content:

  • con => database object instance
  • cols => number of columns
  • rows => number of rows
  • info[name] => an array with columns names
  • info[type] => an array with columns types
Parameters
mixed$resultResource result
array$infoInformation array

References index().

Member Function Documentation

◆ toStatic()

toStatic ( )

To staticRecord

Converts this record to a staticRecord instance.

◆ __call()

__call ( string  $f,
  $args 
)

Magic call

Magic call function. Calls function added by extend() if exists, passing it self object and arguments.

Parameters
string$fFunction name
mixed$argsArguments
Returns
mixed

◆ __get()

__get (   $n)

Magic get

Alias for field().

Parameters
string | int$nField name or field position
Returns
mixed

References field().

◆ f()

f (   $n)

Get field

Alias for field().

Parameters
string | int$nField name or field position
Returns
mixed

References field().

◆ field()

field (   $n)

Get field

Retrieve field value by its name or column position.

Parameters
string | int$nField name or field position
Returns
mixed

Reimplemented in staticRecord.

Referenced by __get(), and f().

◆ exists()

exists (   $n)

Field exists

Returns true if a field exists.

Parameters
string$nField name
Returns
bool

Reimplemented in staticRecord.

◆ __isset()

__isset ( string  $n)

Field isset

Returns true if a field exists (magic method from PHP 5.1).

Parameters
string$nField name
Returns
bool

◆ extend()

extend ( string  $class)

Extend record

Extends this instance capabilities by adding all public static methods of $class to current instance. Class methods should take at least this record as first parameter.

See also
__call()
Parameters
string$classClass name

◆ extensions()

extensions ( )

Returns record extensions.

Returns
array

References $__extend.

◆ index()

index ( ?int  $row = null)

Returns the current index position (0 is first) or move to $row if specified.

Parameters
int$rowRow number to move
Returns
int|boolean

Reimplemented in staticRecord.

References $__index.

Referenced by __construct(), fetch(), key(), moveEnd(), moveNext(), movePrev(), and moveStart().

◆ fetch()

fetch ( )

One step move index

This method moves index forward and return true until index is not the last one. You can use it to loop over record. Example: <?php while ($rs->fetch()) { echo $rs->field1; } ?>

Returns
bool

References $__index, and index().

Referenced by next(), and rewind().

◆ moveStart()

moveStart ( )

Moves index to first position.

Returns
bool

References index().

Referenced by rewind().

◆ moveEnd()

moveEnd ( )

Moves index to last position.

Returns
bool

References index().

◆ moveNext()

moveNext ( )

Moves index to next position.

Returns
bool

References index().

◆ movePrev()

movePrev ( )

Moves index to previous position.

Returns
bool

References index().

◆ isEnd()

isEnd ( )
Returns
bool true if index is at last position

References count().

◆ isStart()

isStart ( )
Returns
bool true if index is at first position.

◆ isEmpty()

isEmpty ( )
Returns
bool true if record contains no result.

References count().

◆ count()

count ( )
Returns
int number of rows in record

Referenced by getData(), isEmpty(), isEnd(), and staticRecord\newFromArray().

◆ columns()

columns ( )
Returns
array array of columns, with name as key and type as value.

◆ rows()

rows ( )
Returns
array all rows in record.

Reimplemented in staticRecord.

References getData().

◆ getData()

getData ( )
protected

All data

Returns an array of all rows in record. This method is called by rows().

Returns
array

References count().

Referenced by rows().

◆ row()

row ( )
Returns
array current rows.

References $__row.

◆ current()

current ( )
See also
Iterator::current

◆ key()

key ( )
See also
Iterator::key

References index().

◆ next()

next ( )
See also
Iterator::next

References fetch().

◆ rewind()

rewind ( )
See also
Iterator::rewind

References fetch(), and moveStart().

◆ valid()

valid ( )
See also
Iterator::valid

Field Documentation

◆ $__link

$__link
protected

◆ $__result

$__result
protected

◆ $__info

$__info
protected

◆ $__extend

$__extend = []
protected

Referenced by extensions().

◆ $__index

$__index = 0
protected

◆ $__row

$__row = false
protected

Referenced by row().


The documentation for this class was generated from the following file: