Overview

Packages

  • awl
    • AuthPlugin
    • AwlDatabase
    • Browser
    • classEditor
    • DataEntry
    • DataUpdate
    • EMail
    • iCalendar
    • MenuSet
    • PgQuery
    • Session
    • Translation
    • User
    • Utilities
    • Validation
    • vCalendar
    • vComponent
    • XMLDocument
    • XMLElement
  • None
  • PHP

Classes

  • DBRecord

Functions

  • sql_from_object
  • sql_from_post
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class DBRecord

A Base class to use for records which will be read/written from the database.

Direct known subclasses

User
Package: awl\DataUpdate
Copyright: Catalyst IT Ltd, Morphoss Ltd <http://www.morphoss.com/>
License: GNU GPL v2 or later
Author: Andrew McMillan <andrew@mcmillan.net.nz>
Located at DataUpdate.php
Methods summary
public
# DBRecord( )

Really numbingly simple construction.

Really numbingly simple construction.

public
# Initialise( string $table, array $keys = array() )

This will read the record from the database if it's available, and the $keys parameter is a non-empty array.

This will read the record from the database if it's available, and the $keys parameter is a non-empty array.

Parameters

$table
string
$table The name of the database table
$keys
array
$keys An associative array containing fieldname => value pairs for the record key.
public
# AddTable( string $table, array $target_list, string $join_clause, string $and_where )

This will join an additional table to the maintained set

This will join an additional table to the maintained set

Parameters

$table
string
$table The name of the database table
$target_list
array
$keys An associative array containing fieldname => value pairs for the record key.
$join_clause
string
$join A PostgreSQL join clause.
$and_where
string
$prefix A field prefix to use for these fields to distinguish them from fields in other joined tables with the same name.
public
# PostToValues( mixed $prefix = "" )

This will assign $_POST values to the internal Values object for each field that exists in the Fields array.

This will assign $_POST values to the internal Values object for each field that exists in the Fields array.

public string
# _BuildJoinClause( )

Builds a table join clause

Builds a table join clause

Returns

string
A simple SQL target join clause excluding the primary table.
public string
# _BuildFieldList( )

Builds a field target list

Builds a field target list

Returns

string
A simple SQL target field list for each field, possibly including prefixes.
public string
# _BuildWhereClause( boolean $overwrite_values = false )

Builds a where clause to match the supplied keys

Builds a where clause to match the supplied keys

Parameters

$overwrite_values
boolean
$overwrite_values Controls whether the data values for the key fields will be forced to match the key values

Returns

string
A simple SQL where clause, including the initial "WHERE", for each key / value.
public mixed
# Set( string $fname, string $fval )

Sets a single field in the record

Sets a single field in the record

Parameters

$fname
string
$fname The name of the field to set the value for
$fval
string
$fval The value to set the field to

Returns

mixed
The new value of the field (i.e. $fval).
public mixed
# Get( string $fname )

Returns a single field from the record

Returns a single field from the record

Parameters

$fname
string
$fname The name of the field to set the value for

Returns

mixed
The current value of the field.
public mixed
# Undefine( string $fname )

Unsets a single field from the record

Unsets a single field from the record

Parameters

$fname
string
$fname The name of the field to unset the value for

Returns

mixed
The current value of the field.
public boolean
# Write( )

To write the record to the database

To write the record to the database

Returns

boolean
Success.
public boolean
# Read( )

To read the record from the database. If we don't have any keys then the record will be blank.

To read the record from the database. If we don't have any keys then the record will be blank.

Returns

boolean
Whether we actually read a record.
Properties summary
public string $Table
#

The database table that this record goes in

The database table that this record goes in

public array $Fields
#

The field names for the record. The array index is the field name and the array value is the field type.

The field names for the record. The array index is the field name and the array value is the field type.

public array $Keys
#

The keys for the record as an array of key => value pairs

The keys for the record as an array of key => value pairs

public object $Values
#

The field values for the record

The field values for the record

public object $WriteType
#

The type of database write we will want: either "update" or "insert"

The type of database write we will want: either "update" or "insert"

public array $OtherTable
#

A list of associated other tables.

A list of associated other tables.

public array $OtherTargets
#

The field names for each of the other tables associated. The array index is the table name, the string is a list of field names (and perhaps aliases) to stuff into the target list for the SELECT.

The field names for each of the other tables associated. The array index is the table name, the string is a list of field names (and perhaps aliases) to stuff into the target list for the SELECT.

public array $OtherJoin
#

An array of JOIN ... clauses. The first array index is the table name and the array value is the JOIN clause like "LEFT JOIN tn t1 USING (myforeignkey)".

An array of JOIN ... clauses. The first array index is the table name and the array value is the JOIN clause like "LEFT JOIN tn t1 USING (myforeignkey)".

public array $OtherWhere
#

An array of partial WHERE clauses. These will be combined (if present) with the key where clause on the main table.

An array of partial WHERE clauses. These will be combined (if present) with the key where clause on the main table.

public object $EditMode
#

The mode we are in for any form

The mode we are in for any form

AWL API documentation generated by ApiGen 2.8.0