Пример #1
0
<?php

/*
* By Silvio Garbes
* Em: 10/11/2015
*/
require_once "../proxieNorthwind.php";
$proxy = new NorthwindEntities();
$response = $proxy->Execute("Customers");
foreach ($response->Result as $customer) {
    echo $customer->CompanyName . ": " . $customer->ContactName . "</br>";
}
$response = $proxy->Customers()->Filter("CustomerID eq 'ALFKI'")->Expand('Orders')->Execute();
$customer = $response->Result[0];
echo count($customer->Orders);
Пример #2
0
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
require_once 'NorthwindEntities.php';
require_once 'urldef.php';
echo "<h3>Sample3: List all cutomer's ID in NorthWind DB with USA as Country and associated Order's ID using LoadProperty and Server Side paging</h3>";
try {
    $svc = new NorthwindEntities(NORTHWIND_SERVICE_URL);
    $query = $svc->Customers()->filter("Country eq 'USA'");
    $customerResponse = $query->Execute();
    $nextCustomerToken = null;
    do {
        if ($nextCustomerToken != null) {
            $customerResponse = $svc->Execute($nextCustomerToken);
        }
        foreach ($customerResponse->Result as $customer) {
            echo '<br/>CustomerID: ' . $customer->CustomerID . "<br/>";
            $nextOrderToken = null;
            echo "<br/>Associated Orders <br/>";
            echo "-----------------------<br/>";
            do {
                $ordersResponse = $svc->LoadProperty($customer, 'Orders', $nextOrderToken);
                foreach ($customer->Orders as $order) {
                    echo "     " . $order->OrderID . "<br/>";
                }
            } while (($nextOrderToken = $ordersResponse->GetContinuation()) != null);
        }
    } while (($nextCustomerToken = $customerResponse->GetContinuation()) != null);
} catch (DataServiceRequestException $ex) {
Пример #3
0
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
require_once 'NorthwindEntities.php';
require_once 'urldef.php';
echo "<h3>Sample2: List all cutomer's ID in NorthWind DB with USA as Country and associated Order's ID using expand option and Server Side paging</h3>";
try {
    $svc = new NorthwindEntities(NORTHWIND_SERVICE_URL);
    $query = $svc->Customers()->filter("Country eq 'USA'")->Expand('Orders');
    $customerResponse = $query->Execute();
    $nextCustomerToken = null;
    do {
        if ($nextCustomerToken != null) {
            $customerResponse = $svc->Execute($nextCustomerToken);
        }
        foreach ($customerResponse->Result as $customer) {
            echo '<br/>CustomerID: ' . $customer->CustomerID . "<br/>";
            $nextOrderToken = null;
            $firstTime = true;
            $ordersResponse;
            echo "<br/>Associated Orders <br/>";
            echo "-----------------------<br/>";
            do {
                $orders = array();
                if (!$firstTime) {
                    $ordersResponse = $svc->Execute($nextOrderToken);
                    $orders = $ordersResponse->Result;
                    $nextOrderToken = $ordersResponse->GetContinuation();
                }