Message from discussion
multiple rows return ?
Received: by 10.142.246.19 with SMTP id t19mr827451wfh.27.1246826421840;
Sun, 05 Jul 2009 13:40:21 -0700 (PDT)
Return-Path: <Dalibor.Andzako...@swerve.co.nz>
Received: from mail.swerve.co.nz (smtp.swerve.co.nz [203.167.214.71])
by gmr-mx.google.com with ESMTP id 22si494887pzk.12.2009.07.05.13.40.20;
Sun, 05 Jul 2009 13:40:21 -0700 (PDT)
Received-SPF: pass (google.com: domain of Dalibor.Andzako...@swerve.co.nz designates 203.167.214.71 as permitted sender) client-ip=203.167.214.71;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of Dalibor.Andzako...@swerve.co.nz designates 203.167.214.71 as permitted sender) smtp.mail=Dalibor.Andzako...@swerve.co.nz
Received: from CrazyHarry.swerve.co.nz ([192.168.254.44]) by
CrazyHarry.swerve.co.nz ([192.168.254.44]) with mapi; Mon, 6 Jul 2009
08:40:19 +1200
From: Dalibor Andzakovic <Dalibor.Andzako...@swerve.co.nz>
To: "phpsoa@googlegroups.com" <phpsoa@googlegroups.com>
Date: Mon, 6 Jul 2009 08:40:18 +1200
Subject: RE: [phpsoa] multiple rows return ?
Thread-Topic: [phpsoa] multiple rows return ?
Thread-Index: Acn9kV+R+5vTxk++QLSuxp0T/UF8/gAHZwtQ
Message-ID: <2B060DB7690FDF44B5A6443DA42F3CAA2A40E2C360@CrazyHarry.swerve.co.nz>
References: <9a5cc463-d9eb-44e8-b294-3a5a3f81d5ed@o18g2000pra.googlegroups.com>
In-Reply-To: <9a5cc463-d9eb-44e8-b294-3a5a3f81d5ed@o18g2000pra.googlegroups.com>
Accept-Language: en-US, en-NZ
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US, en-NZ
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
One way you could achieve this is:
XSD:
<xsd:complexType name=3D"EmployeeList">
<xsd:sequence>
<xsd:element name=3D"Employee" type=3D"EmployeeList_T" minOccurs=3D"0" max=
Occurs=3D"unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=3D"EmployeeList_T">
<xsd:sequence>
<xsd:element name=3D"employeeID" type=3D"xsd:integer" />
<xsd:element name=3D"employeeName" type=3D"xsd:string" />
<xsd:element name=3D"employeeAddress" type=3D"xsd:string" />
</xsd:sequence>
</xsd:complexType>
PHP
$sth =3D $this->PDO->prepare("SELECT employeeID, employeeName, employeeAddr=
ess FROM EMPLOYEE;");
$sth->execute();
=09
$employeeList =3D SCA::createDataObject('your/xsd/namespace', 'EmployeeList=
'); =09
while($row =3D $sth->fetch(PDO::FETCH_OBJ)){ =09
$employee =3D $employeeList->createDataObject('Employee');
$employee->employeeID =3D $row->employeeID;
$employee->employeeName =3D $row->employeeName;
$employee->employeeAddress =3D $row->employeeAddress;
}
There is probably a nicer way to merge the resulting row object into the SD=
O object, but you get the idea.
HTH
dali
-----Original Message-----
From: phpsoa@googlegroups.com [mailto:phpsoa@googlegroups.com] 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.