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

Class: KeyDef

Source Location: /jargon/KeyDef.php

Class Overview


A KeyDef is a way to define the key columns in a table.


Author(s):

Version:

  • $Revision: 1.3 $

Methods



Class Details

[line 60]
A KeyDef is a way to define the key columns in a table.

The KeyDef is generally used in conjunction with a TableDataSet. Essentially a KeyDef is what forms the WHERE clause for an UPDATE or DELETE.

In order to use the KeyDef, you simply use it like this:

  1. $kd = new KeyDef()
  2. $kd->addAttrib("key_column_a");
  3.  
  4. $tds = new TableDataSet($conn, "table", $kd);
  5. $tds->fetchRecords();
  6. $rec = $tds->getRecord(0);
  7. $rec->setValue("column_name", "new value" );
  8. $rec->save();
  9. $tds->close();

In the above example, Record 0 is retrieved from the database table and the following update statement is generated:

 UPDATE table SET column_name=? WHERE key_column_a=?




Tags:

author:  Jon S. Stevens <jon@latchkey.com> (Village)
version:  $Revision: 1.3 $
author:  Hans Lellelid <hans@xmpl.org> (Jargon)
see:  TableDataSet::refresh()
see:  TableDataSet::doDelete()
see:  TableDataSet::doUpdate()


[ Top ]


Class Methods


constructor __construct [line 78]

KeyDef __construct( )

Construct a keydef.

Accepts a variable number of arguments -- a list of coluns to use for keydef:

  1. $kd = new KeyDef('id'); // id col is pkey
  2. $kd = new KeyDef('key1', 'key2');




Tags:

access:  public


[ Top ]

method addAttrib [line 89]

KeyDef addAttrib( string $name)

Adds the named attribute to the KeyDef.



Tags:

return:  The modified class.
access:  public


Parameters:

string   $name  

[ Top ]

method containsAttrib [line 101]

boolean containsAttrib( string $name)

Determines if the KeyDef contains the requested Attribute.



Tags:

return:  True if the attribute has been defined. false otherwise.
access:  public


Parameters:

string   $name  

[ Top ]

method getAttrib [line 111]

string getAttrib( int $pos)

getAttrib is 1 based. Setting pos to 0 will attempt to return pos 1.



Tags:

return:  Value of attribute at pos as String. null if value is not found.
access:  public


Parameters:

int   $pos   1-based position of attrib.

[ Top ]

method size [line 122]

int size( )

Returns number of columns in KeyDef.



Tags:

return:  The number of elements in the KeyDef that were set by addAttrib()
access:  public
see:  KeyDef::addAttrib()


[ Top ]


Documentation generated on Mon, 23 Aug 2004 21:51:32 -0400 by phpDocumentor 1.3.0RC3