Browse files

add bulk write demo

  • Loading branch information...
1 parent 348a2f0 commit 8ff1e55e4a5b1a9121319a3275655416d70b9366 Andrew J Cronk committed Feb 8, 2012
Showing with 32 additions and 4 deletions.
  1. +28 −0 tempodb-bulk-write-demo.php
  2. +2 −2 tempodb-read-demo.php
  3. +2 −2 tempodb-write-demo.php
View
28 tempodb-bulk-write-demo.php
@@ -0,0 +1,28 @@
+<?php
+/* http://tempo-db.com/api/write-series/#bulk-write-multiple-series */
+
+require('./tempodb.php');
+date_default_timezone_set("America/Chicago");
+
+$tdb = new TempoDB("myagley", "opensesame");
+
+$series_key1 = "custom-series-key1";
+$series_key2 = "custom-series-key2";
+$series_key3 = "custom-series-key3";
+$series_key4 = "custom-series-key4";
+
+
+$data = array(
+ 't' => date("c"),
+ 'data' => array(
+ array('key' => $series_key1, 'v' => 1.11),
+ array('key' => $series_key2, 'v' => 2.22),
+ array('key' => $series_key3, 'v' => 3.33),
+ array('key' => $series_key4, 'v' => 4.44),
+ )
+);
+// write bulk data
+$result = $tdb->write_bulk($data);
+var_dump($result);
+
+?>
View
4 tempodb-read-demo.php
@@ -1,4 +1,6 @@
<?php
+/* http://tempo-db.com/api/read-series/#read-series-by-key */
+
require('./tempodb.php');
date_default_timezone_set("America/Chicago");
@@ -8,8 +10,6 @@
$start = new DateTime("2011-01-03");
$end = new DateTime("2011-01-06");
-/* http://tempo-db.com/api/read-series/#read-series-by-key */
-
/* read query with no rollup interval or function specified */
/* rollup interval will be auto-calculated based on start-end date read */
View
4 tempodb-write-demo.php
@@ -1,13 +1,13 @@
<?php
+/* http://tempo-db.com/api/write-series/#write-series-by-key */
+
require('./tempodb.php');
date_default_timezone_set("America/Chicago");
$tdb = new TempoDB("your-api-key", "your-api-secret");
$series_key = "custom-series-key";
-/* http://tempo-db.com/api/write-series/#write-series-by-key */
-
$date = new DateTime("2012-01-01");

0 comments on commit 8ff1e55

Please sign in to comment.