Документация PHP


Примеры

SDO Функции

Примеры

PHP Manual


Reflecting on Service Data Objects

SDOs have a knowledge of the structure they have been created to represent (the model). For example, a Company SDO created using the Company XML schema above would only be permitted to contain DepartmentType data objects which in turn could only contain EmployeeType data objects.

Sometimes it is useful to be able to access this model information at runtime. For example, this could be used to automatically generate a user interface for populating a data object. The model information is accessed using reflection.

Пример #1 Reflecting on a Data Object

The following example shows how we can reflect on an empty Employee data object.

<?php
  
// Create the employee data object (e.g. from an XML Data Access Service)
  
$employee = ...;
  
$reflection = new SDO_Model_ReflectionDataObject($employee);
  print(
$reflection);
?>

Результат выполнения данного примера:

object(SDO_Model_ReflectionDataObject)#4 { - ROOT OBJECT - Type { 
companyNS:EmployeeType[3] { commonj.sdo:String $name; 
commonj.sdo:String $SN; commonj.sdo:Boolean $manager; } }

Using print on the SDO_Model_ReflectionDataObject writes out the data object's model. We can see from the output how the type companyNS:EmployeeType has three properties and we can see the names of the properties along with their types. Note, the primitive types are listed as SDO types (e.g. commonj.sdo namespace, String type). It is worth noting that this is the SDO model and when these are surfaced to an application they can be treated as the PHP equivalent types (e.g. string and boolean).

Пример #2 Accessing the type information

We can query the type information of a data object using reflection. The following example checks the type corresponds to a data object rather than a primitive and then iterates through the properties of the type, writing out the name of each property ($type and $property are SDO_Model_Type and SDO_Model_Property objects, respectively).

<?php
    
// Create the employee data object (e.g. from an XML Data Access Service)
    
$employee = ...;
    
$reflection = new SDO_Model_ReflectionDataObject($employee);
    
$type $reflection->getType();
    if (! 
$type->isDataType()) {
        foreach (
$type->getProperties() as $property) {
            print 
$property->getName() . "\n";
        }
    }
?>

Результат выполнения данного примера:

name
SN
manager


Примеры

SDO Функции

Примеры

PHP Manual

SAPE все усложнил?

MainLink - простая и прибыльная продажа ссылок!

Последние поступления:

Размещена 10 августа 2020 года

Я по ТВ видел, что через 10 лет мы будем жить лучше, чем в Германии...
Я не понял, что это они с Германией сделать хотят?!

читать далее…

ТехЗадание на Землю

Размещена 14 марта 2018 года

Пpоект Genesis (из коpпоpативной пеpеписки)

читать далее…

Шпаргалка по работе с Vim

Размещена 05 декабря 2017 года

Vim довольно мощный редактор, но работа с ним не всегда наглядна.
Например если нужно отредактировать какой-то файл например при помощи crontab, без знания специфики работы с viv никак.

читать далее…

Ошибка: Error: Cannot find a valid baseurl for repo

Размещена 13 сентабря 2017 года

Если возникает ошибка на centos 5 вида
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/

читать далее…

Linux Optimization

Размещена 30 июля 2012 года

Prelink

читать далее…