public function testReplaceJson()
 {
     $this->markTestSkipped("Concurrent writing to a dataset doesn't work");
     $ds = new SodaDataset($this->client, $this->id);
     $json = file_get_contents("tests/datasets/dataset.json");
     $ds->replace($json);
 }
 public function testDeleteRow()
 {
     $ds = new SodaDataset($this->client, $this->id);
     $soql = new SoqlQuery();
     $soql->select(":id,date,os,visits");
     $result = $ds->getDataset($soql);
     $uID = $result[0][':id'];
     $ds->deleteRow($uID);
     $soql->select(':id')->where(':id = ' . $uID);
     $new_result = $ds->getDataset($soql);
     $this->assertEmpty($new_result);
 }
示例#3
0
 public function testOrderDescQuery()
 {
     $soql = new SoqlQuery();
     $soql->order("state", SoqlOrderDirection::DESC)->limit(5);
     $results = $this->dataset->getDataset($soql);
     $loop_iterations = count($results) - 1;
     for ($i = 0; $i < $loop_iterations; $i++) {
         $this->assertGreaterThanOrEqual($results[$i + 1]['state'], $results[$i]['state']);
     }
 }
示例#4
0
 public function testGetDatasetWithArrayFilter()
 {
     $arrayFilter = array("state" => "AZ");
     $ds = new SodaDataset($this->client, $this->id);
     $results = $ds->getDataset($arrayFilter);
     foreach ($results as $result) {
         $this->assertEquals("AZ", $result['state']);
     }
 }
示例#5
0
 /**
  * @expectedException allejo\Socrata\Exceptions\SodaException
  */
 public function testMultipleOrderQueryWithApiV1()
 {
     $soql = new SoqlQuery();
     $soql->order("state", SoqlOrderDirection::DESC)->order("date_posted", SoqlOrderDirection::ASC)->limit(5);
     $this->dataset->getDataset($soql);
 }
示例#6
0
<?php

// PhpSoda is packaged up in a Phar archive which allows us to include the entire library with a single "include."
// You may also use "include_once," "require," or "require_once"
include "phpsoda-0.1.0.phar";
// PhpSoda organizes its code inside namespaces; in order to use PhpSoda, you'll have to "use" the namespaces. These
// three namespaces should suffice for most code.
use allejo\Socrata\SodaClient;
use allejo\Socrata\SodaDataset;
use allejo\Socrata\SoqlQuery;
// If someone has pushed the "Submit" button, this'll be set to true
$postBack = $_SERVER['REQUEST_METHOD'] == 'POST';
if ($postBack) {
    // Our client will store information about the host, token, and authentication (if necessary)
    $sc = new SodaClient("data.seattle.gov", "B0ixMbJj4LuQVfYnz95Hfp3Ni");
    $ds = new SodaDataset($sc, "pu5n-trf4");
    // Build a SoqlQuery with functions
    $soql = new SoqlQuery();
    $soql->where("within_circle(incident_location, {$_POST['latitude']}, {$_POST['longitude']}, {$_POST['range']})")->limit(20);
    // Get the dataset. $results is now an associative array in the same format as the JSON object
    $results = $ds->getDataset($soql);
}
?>

<html>
    <head>
        <title>Seattle Police Department 911 Incident Response</title>
    </head>
    <body>
        <h1>Seattle Police Department 911 Incident Response</h1>