PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TDataFieldAccessor

TDataFieldAccessor class

TDataFieldAccessor is a utility class that provides access to a field of some data. The accessor attempts to obtain the field value in the following order:

  • If the data is an array, then the field is treated as an array index and the corresponding element value is returned;
  • If the data is a TMap or TList object, then the field is treated as a key into the map or list, and the corresponding value is returned.
  • If the data is an object, the field is treated as a property or sub-property defined with getter methods. For example, if the object has a method called getMyValue(), then field 'MyValue' will retrieve the result of this method call. If getMyValue() returns an object which contains a method getMySubValue(), then field 'MyValue.MySubValue' will return that method call result.
Package: System\Util
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at Util/TDataFieldAccessor.php
Methods summary
public static mixed
# getDataFieldValue( mixed $data, mixed $field )

Evaluates the data value at the specified field.

  • If the data is an array, then the field is treated as an array index

    and the corresponding element value is returned; the field name can also include

    dots to access subarrays. For example a field named 'MyField.MySubField' will

    first try to access $data['MyField.MySubField'], then try $data['MyField']['MySubField'].

  • If the data is a TMap or TList object, then the field is treated as a key

    into the map or list, and the corresponding value is returned.

  • If the data is an object, the field is treated as a property or sub-property

    defined with getter methods. For example, if the object has a method called

    getMyValue(), then field 'MyValue' will retrieve the result of this method call.

    If getMyValue() returns an object which contains a method getMySubValue(),

    then field 'MyValue.MySubValue' will return that method call result.

Evaluates the data value at the specified field.

  • If the data is an array, then the field is treated as an array index and the corresponding element value is returned; the field name can also include dots to access subarrays. For example a field named 'MyField.MySubField' will first try to access $data['MyField.MySubField'], then try $data['MyField']['MySubField'].
  • If the data is a TMap or TList object, then the field is treated as a key into the map or list, and the corresponding value is returned.
  • If the data is an object, the field is treated as a property or sub-property defined with getter methods. For example, if the object has a method called getMyValue(), then field 'MyValue' will retrieve the result of this method call. If getMyValue() returns an object which contains a method getMySubValue(), then field 'MyValue.MySubValue' will return that method call result.

Parameters

$data
mixed
data containing the field value, can be an array, TMap, TList or object.
$field
mixed
field value

Returns

mixed
value at the specified field

Throws

TInvalidDataValueException
if field or data is invalid
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO