DatabaseIterator
[ class tree: DatabaseIterator ] [ index: DatabaseIterator ] [ all elements ]

Class: TableIterator

Source Location: /database_iterator.class.php

Class Overview


Class TableIterator


Author(s):

Version:

  • 0.1

Implements interfaces:

  • Iterator (internal interface)
  • ArrayAccess (internal interface)

Variables

Methods



Class Details

[line 207]
Class TableIterator

DatabaseIterator use TableIterator, RowIterator and ColumnIterator classes to manipulate database using SPL features. This class implements Iterator and ArrayAccess interfaces; and extends of ArrayObject

  1.  // $conn is an ADOConnection object
  2.  $dbIt new DatabaseIterator($conn);
  3.  $table $dbIt['tablename']// TableIterator
  4.  echo $table[0]->field1// Access to field1 column of the first row




Tags:

version:  0.1
see:  DatabaseIterator


[ Top ]


Class Variables

$db =  null

[line 216]



Tags:

access:  public
usedby:  TableIterator::total()

Type:   ADOConnection


[ Top ]

$name =  null

[line 211]



Tags:

access:  public

Type:   string


[ Top ]



Class Methods


constructor __construct [line 246]

TableIterator __construct( string $name, ADOConnection $db)

Constructor



Tags:

access:  public


Parameters:

string   $name   Name of table
ADOConnection   $db   ADOConnection instance

[ Top ]

method current [line 569]

void current( )




Implementation of:
Iterator::current
[ Top ]

method each [line 291]

void each( string $callback)

Iterate across rows calling to $callback with row parameter

  1.  $foo create_function('$row''echo $row->field1;');
  2.  $dbIt['tablename']->each($foo);




Tags:

link:  www.php.net/create_function
access:  public


Parameters:

string   $callback   Callback name or lambda function (create_function)

[ Top ]

method execute [line 376]

ArrayIterator execute( )

Perform SQL query and return a Iterator object



Tags:

access:  public
usedby:  TableIterator::loadRows()
uses:  TableIterator::getIterator()


[ Top ]

method getColumns [line 452]

array getColumns( )

Return columns for this table



Tags:

return:  Return an array of ColumnIterator
access:  public


[ Top ]

method getCreateTable [line 481]

string getCreateTable( )

Get SQL syntax of CREATE TABLE sentence for this table



Tags:

return:  Return the CREATE TABLE sql syntax
access:  public


[ Top ]

method getIterator [line 403]

ArrayIterator getIterator( )

Make a ArrayObject with internal array of rows and return the ArrayIterator



Tags:

see:  TableIterator::execute()
access:  public
usedby:  TableIterator::execute()


[ Top ]

method getPrimaryKeys [line 461]

array getPrimaryKeys( )

Get primary keys for this table



Tags:

return:  Return array with primary keys ('columnName' => ColumnIterator object)
access:  public


[ Top ]

method init [line 261]

void init( [boolean $conditions = false])

Reset internal array of rows $_rows and reset conditions to SQL execution if $conditions is true



Tags:

access:  public
usedby:  TableIterator::insert()


Parameters:

boolean   $conditions   If $conditions is true then reset SQL internal query

[ Top ]

method insert [line 520]

void insert( $data)

Create a new RowIterator object an insert $data into database.

The internal array ($_rows) will be empty to perform a new query to database and to retrieve fresh data.

  1.  for($i=0$i<10$i++{
  2.      $std new stdClass();
  3.      $std->pk_field ($i+1);
  4.      $std->integer 0;
  5.      $std->text 'Testing '.$i;
  6.  
  7.      $dbIt['tablename']->insert($std);
  8.  }




Tags:

see:  RowIterator::insert()
access:  public
uses:  TableIterator::newRow()
uses:  TableIterator::init()


Parameters:

   $data  

[ Top ]

method key [line 574]

void key( )




Implementation of:
Iterator::key
[ Top ]

method length [line 366]

integer length( )

Count internal rows



Tags:

return:  Return total rows into $_rows internal array
access:  public


[ Top ]

method limit [line 345]

RowIterator limit( string $limit)

Set limit parameter to internal SQL



Tags:

return:  Return $this reference to perform chaining method
access:  public


Parameters:

string   $limit   Limit sentence to SQL query

[ Top ]

method loadRows [line 417]

void loadRows( )

Load rows, perform a call to execute method



Tags:

access:  public
uses:  TableIterator::execute()


[ Top ]

method newRow [line 496]

RowIterator newRow( )

Return a empty row to process a insert operation



Tags:

return:  Return a new RowIterator object
access:  public
usedby:  TableIterator::insert()


[ Top ]

method next [line 579]

void next( )




Implementation of:
Iterator::next
[ Top ]

method offsetExists [line 595]

void offsetExists( $offset)



Tags:

access:  public



Implementation of:
ArrayAccess::offsetExists

Parameters:

   $offset  

[ Top ]

method offsetGet [line 605]

void offsetGet( $offset)



Tags:

access:  public



Implementation of:
ArrayAccess::offsetGet

Parameters:

   $offset  

[ Top ]

method offsetSet [line 590]

void offsetSet( $offset, $value)



Tags:

access:  public



Implementation of:
ArrayAccess::offsetSet

Parameters:

   $offset  
   $value  

[ Top ]

method offsetUnset [line 600]

void offsetUnset( $offset)



Tags:

access:  public



Implementation of:
ArrayAccess::offsetUnset

Parameters:

   $offset  

[ Top ]

method order_by [line 356]

RowIterator order_by( string $order_by)

Set "order by" parameter to internal SQL



Tags:

return:  Return $this reference to perform chaining method
access:  public


Parameters:

string   $order_by   "Order by" sentence to SQL query

[ Top ]

method rewind [line 564]

void rewind( )




Implementation of:
Iterator::rewind
[ Top ]

method select [line 323]

RowIterator select( [string $cols = '*'])

Set select parameter to internal SQL

  1.  $rows $dbIt['tablename']->select('pk_field, content')->where('content LIKE "Nothing"')->execute();




Tags:

return:  Return $this reference to perform chaining method
access:  public


Parameters:

string   $cols   Select sentence to SQL query

[ Top ]

method setDatabase [line 277]

void setDatabase( ADOConnection $db)

Set database object (ADOConnection)



Tags:

access:  public


Parameters:

ADOConnection   $db  

[ Top ]

method total [line 307]

int total( )

Return the number of rows in this table. This method don't use "where" conditions to recover total rows number.



Tags:

return:  Total rows for table
access:  public
uses:  TableIterator::$db


[ Top ]

method valid [line 584]

void valid( )




Implementation of:
Iterator::valid
[ Top ]

method where [line 334]

RowIterator where( string $where)

Set where parameter to internal SQL



Tags:

return:  Return $this reference to perform chaining method
access:  public


Parameters:

string   $where   Where sentence to SQL query

[ Top ]


Documentation generated on Mon, 25 May 2009 19:28:29 +0200 by phpDocumentor 1.4.2