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

Class: DB_DataObject_Links

Source Location: /DB_DataObject-1.11.5/DB/DataObject/Links.php

Class Overview


Links class


Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 39]
Links class


[ Top ]


Class Variables

$apply =  true

[line 69]


Type:   mixed


[ Top ]

$cached =  false

[line 65]


Type:   mixed


[ Top ]

$do =  false

[line 44]


Type:   mixed


[ Top ]

$links =

[line 76]


Type:   mixed


[ Top ]

$load =  'all'

[line 50]


Type:   mixed


[ Top ]

$printf =  false

[line 60]


Type:   mixed


[ Top ]

$scanf =  false

[line 55]


Type:   mixed


[ Top ]



Method Detail

DB_DataObject_Links (Constructor)   [line 86]

DB_DataObject_Links DB_DataObject_Links( {DB_DataObject} $do, [{Array} $cfg = array()])

Constructor -- good ole style..

Parameters:

{DB_DataObject}   $do   —  do DataObject to apply to.
{Array}   $cfg   —  cfg Configuration (basically properties of this object)

[ Top ]

applyLinks   [line 354]

boolean applyLinks( [string $format = '_%s'])

load related objects

Generally not recommended to use this. The generator should support creating getter_setter methods which are better suited.

Relies on <dbname>.links.ini

Sets properties on the calling dataobject you can change what object vars the links are stored in by changeing the format parameter

  • Return: , true on success
  • Author: Tim White <tim@cyface.com>
  • Access: public

Parameters:

string   $format   —  format (default _%s) where %s is the table name.

[ Top ]

getLink   [line 113]

mixed getLink( $field, [string|DB_DataObject $table = false], [string $link = ''], string $field|array)

return name from related object

The relies on a <dbname>.links.ini file, unless you specify the arguments.

you can also use $this->getLink('thisColumnName','otherTable','otherTableColumnName')

  • Return: object on success false on failure or '0' when not linked
  • Author: Tim White <tim@cyface.com>
  • Access: public

Parameters:

string   $field|array   —  either row or row.xxxxx or links spec.
string|DB_DataObject   $table   —  (optional) name of table to look up value in
string   $link   —  (optional) name of column in other table to match
   $field   — 

[ Top ]

getLinkArray   [line 437]

array getLinkArray( $field, [string $table = null], [string $fkey = false], [string $fval = false], [ $fmethod = false], string $field-)

getLinkArray Fetch an array of related objects. This should be used in conjunction with a <dbname>.links.ini file configuration (see the introduction on linking for details on this).

You may also use this with all parameters to specify, the column and related table.

  • Return:

    - array of results (empty array on failure)

    Example - Getting the related objects

    $person = new DataObjects_Person; $person->get(12); $children = $person->getLinkArray('children');

    echo 'There are ', count($children), ' descendant(s):
    '; foreach ($children as $child) { echo $child->name, '
    '; }

  • Access: public

Parameters:

string   $field-   —  either column or column.xxxxx
string   $table   —  (optional) name of table to look up value in
string   $fkey   —  (optional) fetchall key see DB_DataObject::fetchAll()
string   $fval   —  (optional) fetchall method DB_DataObject::fetchAll()
   $field   — 
   $fmethod   — 

[ Top ]

link   [line 280]

mixed link( string|array $field, [ $args = array()])

a generic geter/setter provider..

provides a generic getter setter for the referenced object eg. $link->link('company_id') returns getLink for the object if nothing is linked (it will return an empty dataObject) $link->link('company_id', array(1)) - just sets the

also array as the field speck supports $link->link(array('company_id', 'company:id'))

  • Return: true of false on set, the object on getter.

Parameters:

string|array   $field   —  the field to fetch or link spec.
   $args   — 

[ Top ]

linkInfo   [line 204]

(false|array) linkInfo( string|array $field)

get link information for a field or field specification

alll link (and join methods accept the 'link' info ) in various ways string : 'field' = which field to get (uses ???.links.ini to work out what) array(2) : 'field', 'table:remote_col' << just like the links.ini def. array(3) : 'field', $dataobject, 'remote_col' (handy for joinAdd to do nested joins.)

  • Return: array of dataobject and linked field or false.

Parameters:

string|array   $field   —  or link spec to use.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 16:03:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.