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

Class: DBA_Relational

Source Location: /DBA_Relational-0.2.0/Relational.php

Class Overview

PEAR
   |
   --DBA_Relational

A relational database manager using DBA_Table as a storage object.


Author(s):

Version:

  • 0.19

Methods


Inherited Variables

Inherited Methods


Class Details

[line 41]
A relational database manager using DBA_Table as a storage object.

DBA_Relational extends DBA_Table by providing uniform access to multiple tables, automatically opening, closing and locking tables as needed by various operations, and provides a join operation.



[ Top ]


Method Detail

DBA_Relational (Constructor)   [line 74]

DBA_Relational DBA_Relational( [string $home = ''], [string $driver = 'file'])

Constructor

Parameters:

string   $home   —  path where data files are stored
string   $driver   —  DBA driver to use

[ Top ]

close   [line 122]

void close( )

Closes all open tables
  • Access: public

[ Top ]

createTable   [line 203]

object PEAR_Error createTable( string $tableName, array $schema, [string $driver = null])

Creates a new table
  • Return: on failure
  • Access: public

Parameters:

string   $tableName   —  name of the table to create
array   $schema   —  field schema for the table
string   $driver   —  driver to use for this table

[ Top ]

dropTable   [line 222]

object PEAR_Error dropTable( string $tableName, [string $driver = null])

Deletes a table permanently
  • Return: on failure
  • Access: public

Parameters:

string   $tableName   —  name of the table to delete
string   $driver   —  driver that created the table

[ Top ]

fetch   [line 381]

mixed fetch( string $tableName, string $key)

Fetches an existing row from a table
  • Return: PEAR_Error on failure, the row array on success
  • Access: public

Parameters:

string   $tableName   —  table on which to operate
string   $key   —  row id to fetch

[ Top ]

finalize   [line 460]

mixed finalize( string $tableName, [array $rows = null])

Converts the results from any of the row operations to a 'finalized'

display-ready form. That means that timestamps, sets and enums are converted into strings. This obviously has some consequences if you plan on chaining the results into another row operation, so don't call this unless it is the final operation.

This function does not yet work reliably with the results of a join operation, due to a loss of metadata

  • Return: PEAR_Error on failure, the row array on success
  • Access: public

Parameters:

string   $tableName   —  table on which to operate
array   $rows   —  rows to finalize, if none are specified, returns the whole table

[ Top ]

getSchema   [line 245]

array getSchema( string $tableName)

Returns an array with the stored schema for the table

Parameters:

string   $tableName   — 

[ Top ]

insert   [line 280]

mixed insert( string $tableName, array $data)

Inserts a new row in a table
  • Return: PEAR_Error on failure, the row index on success

Parameters:

string   $tableName   —  table on which to operate
array   $data   —  assoc array or ordered list of data to insert

[ Top ]

isOpen   [line 262]

boolean isOpen( $tableName)

Returns the current read status for the database

Parameters:

   $tableName   — 

[ Top ]

join   [line 653]

mixed join( string $tableA, string $tableB, string $rawQuery)

Joins rows between two tables based on a query.
  • Return: PEAR_Error on failure, the row array on success
  • Access: public

Parameters:

string   $tableA   —  name of table to join
string   $tableB   —  name of table to join
string   $rawQuery   —  expression of how to join tableA and tableB

[ Top ]

joinTables   [line 539]

object PEAR_Error &joinTables( $tableA $tableA, $tableB $tableB, [ $clause = true], [$type $type = 'inner'], string $query, array $option)

Makes a new table joining 2 existing tables
  • Return: on failure, DBA_TempTable on success
  • Access: public

Parameters:

string   $query   —  query expression for performing the select
array   $option   —  join options
$tableA   $tableA   —  mixed table name or object to join
$tableB   $tableB   —  mixed table name or object to join
$type   $type   —  string 'inner','outer','right','left'
   $clause   — 

[ Top ]

project   [line 422]

mixed project( array $fields, array $rows)

Projects rows by field. This means that a subset of the possible fields are in the resulting rows. The SQL analog is 'select fields from table'
  • Return: PEAR_Error on failure, the row array on success
  • Access: public

Parameters:

array   $fields   —  fields to project
array   $rows   —  rows to project, projects entire table if not specified

[ Top ]

raiseError   [line 111]

void raiseError( $message)


Parameters:

   $message   — 

[ Top ]

remove   [line 341]

object PEAR_Error remove( $tableName, string $rawQuery, [array $rows = null])

Removes rows that match $rawQuery with $
  • Return: on failure
  • Access: public

Parameters:

string   $rawQuery   —  query expression for performing the remove
array   $rows   —  subset of rows to choose from
   $tableName   — 

[ Top ]

removeKey   [line 361]

object PEAR_Error removeKey( string $tableName, string $key)

Remove an existing row in a table
  • Return: on failure
  • Access: public

Parameters:

string   $tableName   —  table on which to operate
string   $key   —  row id to remove

[ Top ]

replace   [line 300]

object PEAR_Error replace( $tableName, string $rawQuery, $data, [array $rows = null])

Replaces rows that match $rawQuery
  • Return: on failure
  • Access: public

Parameters:

string   $rawQuery   —  query expression for performing the replace
array   $rows   —  subset of rows to choose from
   $tableName   — 
   $data   — 

[ Top ]

replaceKey   [line 321]

mixed replaceKey( string $tableName, string $key, array $data)

Replaces an existing row in a table, inserts if the row does not exist
  • Return: PEAR_Error on failure, the row index on success
  • Access: public

Parameters:

string   $tableName   —  table on which to operate
string   $key   —  row id to replace
array   $data   —  assoc array or ordered list of data to insert

[ Top ]

select   [line 515]

mixed select( string $tableName, [string $query = '*'], [ $rows = null])

Performs a select on a table. This means that a subset of rows in a

table are filtered and returned based on the query. Accepts any valid expression of the form '(field == field) || (field > 3)', etc. Using the expression '*' returns the entire table SQL analog: 'select * from rows where rawQuery'

  • Return: PEAR_Error on failure, the row array on success
  • Access: public

Parameters:

string   $tableName   —  table on which to operate
string   $query   —  query expression for performing the select
   $rows   — 

[ Top ]

sort   [line 405]

mixed sort( mixed $fields, [string $order = 'a'], array $rows)

Sorts rows by field in either ascending or descending order SQL analog: 'select * from rows, order by fields'
  • Return: PEAR_Error on failure, the row array on success
  • Access: public

Parameters:

mixed   $fields   —  a string with the field name to sort by or an array of fields to sort by in order of preference
string   $order   —  'a' for ascending, 'd' for descending
array   $rows   —  rows to sort, sorts the entire table if not specified

[ Top ]

tableExists   [line 187]

boolean tableExists( string $tableName)

Returns whether the specified table exists in the db home
  • Return: true if the table exists, false if it doesn't

Parameters:

string   $tableName   —  table to check existence of

[ Top ]

unique   [line 437]

mixed unique( array $rows)

Returns the unique rows from a set of rows
  • Return: PEAR_Error on failure, the row array on success
  • Access: public

Parameters:

array   $rows   —  rows to process, uses entire table if not specified

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:59:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.