public function testAllIterate() { $ixps = IXF\ApiResource::all('IXP'); // note that we can use the IXP class also: $last = IXF\IXP::all('IXP', ['limit' => 2]); $this->assertEquals(2, count($last)); // iterate over records 2 at a time foreach (range(1, count($ixps) - 2) as $i) { $objs = IXF\ApiResource::all('IXP', ['limit' => 2, 'skip' => $i]); $this->assertEquals(2, count($objs)); $this->assertGreaterThan($objs[0]->id, $objs[1]->id); $this->assertEquals($last[1], $objs[0]); $last = $objs; } }
require_once __DIR__ . "/../lib/IXF/Util/Set.php"; require_once __DIR__ . "/../lib/IXF/Object.php"; require_once __DIR__ . "/../lib/IXF/ApiResource.php"; require_once __DIR__ . "/../lib/IXF/AttachedObject.php"; require_once __DIR__ . "/../lib/IXF/IXP.php"; require_once __DIR__ . "/../lib/IXF/Error.php"; require_once __DIR__ . "/../lib/IXF/Error/Api.php"; require_once __DIR__ . "/../lib/IXF/Error/ApiConnection.php"; require_once __DIR__ . "/../lib/IXF/Error/InvalidRequest.php"; // set the API endpoint and authentication parameters IXF\IXF::setApiBase('https://dev0.lo0.20c.com:7010/api'); IXF\IXF::setApiUser('guest'); IXF\IXF::setApiPass('guest'); IXF\IXF::setVerifySslCerts(false); // find five IXPs starting at 10 $objs = IXF\IXP::all(['skip' => 10, 'limit' => 5]); if (is_array($objs) && isset($objs['error'])) { var_dump($objs); die; } foreach ($objs as $o) { echo $o->full_name . '[' . $o->short_name . '] => ' . $o->lat . ', ' . $o->lon . "\n"; } // let's edit the last one from above echo "ID/Short name before: " . $o->id . '/' . $o->short_name . "\n"; $old_short_name = $o->short_name; $o->short_name = 'EDITED'; // returns true on success (or no updates needed) if (($err = $o->save()) !== true) { // on failure, an array of the form: // array(1) {