Overview

Packages

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

Classes

  • DBRecord

Functions

  • sql_from_object
  • sql_from_post
  • Overview
  • Package
  • Class

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
The name of the database table
$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
The name of the database table
$target_list
$keys An associative array containing fieldname => value pairs for the record key.
$join_clause
$join A PostgreSQL join clause.
$and_where

$prefix A field prefix to use for these fields to distinguish them from fields in other joined tables with the same name.

public
# PostToValues( $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
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
The name of the field to set the value for
$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
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
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

#
API documentation generated by ApiGen