class Doctrine_Template_Geographical extends Doctrine_Template (View source)

Easily add longitude and latitude columns to your records and use inherited functionality for calculating distances

Properties

protected Doctrine_Locator $_locator from Doctrine_Locator_Injectable
protected array $_resources from Doctrine_Locator_Injectable
static protected Doctrine_Null $_null from Doctrine_Locator_Injectable
protected $_table from Doctrine_Record_Abstract
protected Doctrine_Record $_invoker from Doctrine_Template
protected Doctrine_Record_Generator $_plugin from Doctrine_Template
protected string $_options Array of geographical options

Methods

setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

getLocator()

getLocator returns the locator associated with this object

mixed
locate(string $name)

locate locates a resource by given name and returns it

bind($name, $resource)

bind binds a resource to a name

static void
initNullObject(Doctrine_Null $null)

initNullObject initializes the null object

static Doctrine_Null
getNullObject()

getNullObject returns the null object associated with this object

setArray(array $array)

Set an entire aray to the data

void
__set($name, $value)

Set key and value to data

mixed
__get(mixed $name)

Get key from data

boolean
__isset(string $name)

Check if key exists in data

void
__unset(string $name)

Remove key from data

boolean
offsetExists(mixed $offset)

Check if an offset axists

mixed
offsetGet(mixed $offset)

An alias of get()

void
offsetSet(mixed $offset, mixed $value)

Sets $offset to $value

offsetUnset(mixed $offset)

Unset a given offset

boolean
remove(mixed $offset)

Remove the element with the specified offset

mixed
get(mixed $name)

get

set(mixed $name, mixed $value)

set

boolean
contains(mixed $offset)

Check if the specified offset exists

void
add(mixed $value)

Add the value

setTableDefinition()

Set table definition for Geographical behavior

setUp()

Blank method for template setup

getTable()

returns the associated table object

addListener($listener, $name = null)

addListener

mixed
index(string $name, array $definition = array())

index defines or retrieves an index if the second parameter is set this method defines an index if not this method retrieves index named $name

void
unique(array $fields, array $options = array(), bool $createUniqueIndex = true)

Defines a n-uple of fields that must be unique for every record.

setAttribute($attr, $value)

No description

setTableName($tableName)

No description

setInheritanceMap($map)

No description

setSubclasses($map)

No description

mixed
attribute(mixed $attr, mixed $value)

attribute sets or retrieves an option

mixed
option(mixed $name, mixed $value = null)

option sets or retrieves an option

hasOne()

Binds One-to-One aggregate relation

hasMany()

Binds One-to-Many / Many-to-Many aggregate relation

void
hasColumn(string $name, string $type = null, integer $length = null, mixed $options = array())

Sets a column definition

void
hasColumns(array $definitions)

Set multiple column definitions at once

void
setColumnOptions($name, array $options)

Customize the array of options for a column or multiple columns. First argument can be a single field/column name or an array of them. The second argument is an array of options.

void
setColumnOption(string $columnName, string $option, string $value)

Set an individual column option

bindQueryParts(array $queryParts)

bindQueryParts binds query parts to given component

actAs(mixed $tpl, array $options = array())

Loads the given plugin.

check(mixed $constraint, string $name = null)

Adds a check constraint.

void
__construct(array $options = array())

__construct

setTable(Doctrine_Table $table)

Set the table object that this Template belongs to

setInvoker(Doctrine_Record_Abstract $invoker)

sets the last used invoker

getInvoker()

returns the last used invoker

Doctrine_Template.
addChild(Doctrine_Template $template)

Adds a plugin as a child to this plugin

void
getPlugin()

Get plugin instance

boolean
hasPlugin()

Check if this template has a generator plugin

array
getOptions()

getOptions returns all options of this template and the associated values

mixed
getOption(string $name, mixed $default = null)

getOption returns the value of given option

getDistanceQuery()

Initiate and get a distance query with the select parts for the number of kilometers and miles between this record and other zipcode records in the database

integer
getDistance(Doctrine_Record $record, $kilometers = false)

Get distance between this record and another

Details

Doctrine_Locator_Injectable setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

Parameters

Doctrine_Locator $locator the locator object

Return Value

Doctrine_Locator_Injectable this instance

Doctrine_Locator getLocator()

getLocator returns the locator associated with this object

if there are no locator locally associated then this method tries to fetch the current global locator

Return Value

Doctrine_Locator

mixed locate(string $name)

locate locates a resource by given name and returns it

if the resource cannot be found locally this method tries to use the global locator for finding the resource

Parameters

string $name the name of the resource

Return Value

mixed the located resource

Exceptions

Doctrine_Locator_Exception if the resource could not be found

See also

Doctrine_Locator::locate

Doctrine_Locator bind($name, $resource)

bind binds a resource to a name

Parameters

$name
$resource

Return Value

Doctrine_Locator this object

static void initNullObject(Doctrine_Null $null)

initNullObject initializes the null object

Parameters

Doctrine_Null $null

Return Value

void

static Doctrine_Null getNullObject()

getNullObject returns the null object associated with this object

Return Value

Doctrine_Null

Doctrine_Access setArray(array $array)

Set an entire aray to the data

Parameters

array $array An array of key => value pairs

Return Value

Doctrine_Access

void __set($name, $value)

Set key and value to data

Parameters

$name
$value

Return Value

void

See also

set, offsetSet

mixed __get(mixed $name)

Get key from data

Parameters

mixed $name

Return Value

mixed

See also

get, offsetGet

boolean __isset(string $name)

Check if key exists in data

Parameters

string $name

Return Value

boolean whether or not this object contains $name

void __unset(string $name)

Remove key from data

Parameters

string $name

Return Value

void

boolean offsetExists(mixed $offset)

Check if an offset axists

Parameters

mixed $offset

Return Value

boolean Whether or not this object contains $offset

mixed offsetGet(mixed $offset)

An alias of get()

Parameters

mixed $offset

Return Value

mixed

See also

get, __get

void offsetSet(mixed $offset, mixed $value)

Sets $offset to $value

Parameters

mixed $offset
mixed $value

Return Value

void

See also

set, __set

offsetUnset(mixed $offset)

Unset a given offset

Parameters

mixed $offset

See also

set, offsetSet, __set

boolean remove(mixed $offset)

Remove the element with the specified offset

Parameters

mixed $offset The offset to remove

Return Value

boolean True if removed otherwise false

mixed get(mixed $name)

get

Parameters

mixed $name

Return Value

mixed

set(mixed $name, mixed $value)

set

Parameters

mixed $name
mixed $value The value to set the offset to

boolean contains(mixed $offset)

Check if the specified offset exists

Parameters

mixed $offset The offset to check

Return Value

boolean True if exists otherwise false

void add(mixed $value)

Add the value

Parameters

mixed $value The value to add

Return Value

void

setTableDefinition()

Set table definition for Geographical behavior

setUp()

Blank method for template setup

Doctrine_Table getTable()

returns the associated table object

Return Value

Doctrine_Table the associated table object

Doctrine_Record addListener($listener, $name = null)

addListener

Parameters

$listener
$name

Return Value

Doctrine_Record

mixed index(string $name, array $definition = array())

index defines or retrieves an index if the second parameter is set this method defines an index if not this method retrieves index named $name

Parameters

string $name the name of the index
array $definition the definition array

Return Value

mixed

void unique(array $fields, array $options = array(), bool $createUniqueIndex = true)

Defines a n-uple of fields that must be unique for every record.

This method Will automatically add UNIQUE index definition and validate the values on save. The UNIQUE index is not created in the database until you use see export().

Parameters

array $fields values are fieldnames
array $options array of options for unique validator
bool $createUniqueIndex Whether or not to create a unique index in the database

Return Value

void

setAttribute($attr, $value)

Parameters

$attr
$value

setTableName($tableName)

Parameters

$tableName

setInheritanceMap($map)

Parameters

$map

setSubclasses($map)

Parameters

$map

mixed attribute(mixed $attr, mixed $value)

attribute sets or retrieves an option

Parameters

mixed $attr
mixed $value

Return Value

mixed

See also

Doctrine_Core::ATTR_* constants availible attributes

mixed option(mixed $name, mixed $value = null)

option sets or retrieves an option

Parameters

mixed $name the name of the option
mixed $value options value

Return Value

mixed

See also

Doctrine_Table::$options availible options

Doctrine_Record hasOne()

Binds One-to-One aggregate relation

Return Value

Doctrine_Record this object

See also

Doctrine_Relation::_$definition

Doctrine_Record hasMany()

Binds One-to-Many / Many-to-Many aggregate relation

Return Value

Doctrine_Record this object

See also

Doctrine_Relation::_$definition

void hasColumn(string $name, string $type = null, integer $length = null, mixed $options = array())

Sets a column definition

Parameters

string $name
string $type
integer $length
mixed $options

Return Value

void

void hasColumns(array $definitions)

Set multiple column definitions at once

Parameters

array $definitions

Return Value

void

void setColumnOptions($name, array $options)

Customize the array of options for a column or multiple columns. First argument can be a single field/column name or an array of them. The second argument is an array of options.

[php] public function setTableDefinition() { parent::setTableDefinition(); $this->setColumnOptions('username', array( 'unique' => true )); }

Parameters

$name
array $options

Return Value

void

void setColumnOption(string $columnName, string $option, string $value)

Set an individual column option

Parameters

string $columnName
string $option
string $value

Return Value

void

Doctrine_Record bindQueryParts(array $queryParts)

bindQueryParts binds query parts to given component

Parameters

array $queryParts an array of pre-bound query parts

Return Value

Doctrine_Record this object

loadGenerator(Doctrine_Record_Generator $generator)

Parameters

Doctrine_Record_Generator $generator

Doctrine_Record actAs(mixed $tpl, array $options = array())

Loads the given plugin.

This method loads a behavior in the record. It will add the behavior also to the record table if it. It is tipically called in see setUp().

Parameters

mixed $tpl if an object, must be a subclass of Doctrine_Template. If a string, Doctrine will try to instantiate an object of the classes Doctrine_Template_$tpl and subsequently $tpl, using also autoloading capabilities if defined.
array $options argument to pass to the template constructor if $tpl is a class name

Return Value

Doctrine_Record this object; provides a fluent interface.

Exceptions

Doctrine_Record_Exception if $tpl is neither an instance of Doctrine_Template subclass or a valid class name, that could be instantiated.

Doctrine_Record check(mixed $constraint, string $name = null)

Adds a check constraint.

This method will add a CHECK constraint to the record table.

Parameters

mixed $constraint either a SQL constraint portion or an array of CHECK constraints. If array, all values will be added as constraint
string $name optional constraint name. Not used if $constraint is an array.

Return Value

Doctrine_Record this object

void __construct(array $options = array())

__construct

Parameters

array $options

Return Value

void

setTable(Doctrine_Table $table)

Set the table object that this Template belongs to

Parameters

Doctrine_Table $table

Doctrine_Template setInvoker(Doctrine_Record_Abstract $invoker)

sets the last used invoker

Parameters

Doctrine_Record_Abstract $invoker the record that invoked the last delegated call

Return Value

Doctrine_Template this object

Doctrine_Record getInvoker()

returns the last used invoker

Return Value

Doctrine_Record the record that invoked the last delegated call

Doctrine_Template. addChild(Doctrine_Template $template)

Adds a plugin as a child to this plugin

Parameters

Doctrine_Template $template

Return Value

Doctrine_Template. Chainable.

void getPlugin()

Get plugin instance

Return Value

void

boolean hasPlugin()

Check if this template has a generator plugin

Return Value

boolean

array getOptions()

getOptions returns all options of this template and the associated values

Return Value

array all options and their values

mixed getOption(string $name, mixed $default = null)

getOption returns the value of given option

Parameters

string $name the name of the option
mixed $default default value if option is not found

Return Value

mixed the value of given option

Doctrine_Query getDistanceQuery()

Initiate and get a distance query with the select parts for the number of kilometers and miles between this record and other zipcode records in the database

Return Value

Doctrine_Query $query

integer getDistance(Doctrine_Record $record, $kilometers = false)

Get distance between this record and another

Parameters

Doctrine_Record $record
$kilometers

Return Value

integer