multiple rows return ?

View: New views
2 Messages — Rating Filter:   Alert me  

multiple rows return ?

by Alex-542 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all,

I have not found any examples that handle multiple rows of data
returned from database. Anyone can please show me an example? What I
have is this

I have a service that returns multiple rows of result from a database
query, for example

SELECT employeeID, employeeName, employeeAddress FROM EMPLOYEE;

Say the returned result is

1 | John | One Road
2 | Mark | Two Road
3 | Luke | Three Road

How can I represent that in xsd and how those results are going to put
into the array to return the result from the services and at the
client side getting and displaying these results?

Thanks in advance for any help.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "phpsoa" group.
To post to this group, send email to phpsoa@...
To unsubscribe from this group, send email to phpsoa+unsubscribe@...
For more options, visit this group at http://groups.google.co.uk/group/phpsoa?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: multiple rows return ?

by Dalibor Andzakovic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


One way you could achieve this is:

XSD:

<xsd:complexType name="EmployeeList">
<xsd:sequence>
        <xsd:element name="Employee" type="EmployeeList_T" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="EmployeeList_T">
<xsd:sequence>
        <xsd:element name="employeeID" type="xsd:integer" />
        <xsd:element name="employeeName" type="xsd:string" />
        <xsd:element name="employeeAddress" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>

PHP

$sth = $this->PDO->prepare("SELECT employeeID, employeeName, employeeAddress FROM EMPLOYEE;");
$sth->execute();
               
$employeeList = SCA::createDataObject('your/xsd/namespace', 'EmployeeList');

while($row = $sth->fetch(PDO::FETCH_OBJ)){
        $employee = $employeeList->createDataObject('Employee');
        $employee->employeeID = $row->employeeID;
        $employee->employeeName = $row->employeeName;
        $employee->employeeAddress = $row->employeeAddress;
}

There is probably a nicer way to merge the resulting row object into the SDO object, but you get the idea.

HTH

dali

-----Original Message-----
From: phpsoa@... [mailto:phpsoa@...] On Behalf Of Alex
Sent: Sunday, 5 July 2009 5:08 a.m.
To: phpsoa
Subject: [phpsoa] multiple rows return ?


Hi all,

I have not found any examples that handle multiple rows of data
returned from database. Anyone can please show me an example? What I
have is this

I have a service that returns multiple rows of result from a database
query, for example

SELECT employeeID, employeeName, employeeAddress FROM EMPLOYEE;

Say the returned result is

1 | John | One Road
2 | Mark | Two Road
3 | Luke | Three Road

How can I represent that in xsd and how those results are going to put
into the array to return the result from the services and at the
client side getting and displaying these results?

Thanks in advance for any help.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "phpsoa" group.
To post to this group, send email to phpsoa@...
To unsubscribe from this group, send email to phpsoa+unsubscribe@...
For more options, visit this group at http://groups.google.co.uk/group/phpsoa?hl=en
-~----------~----~----~----~------~----~------~--~---