m0n0lithic

PHP PDO::sqlite3 BLOB with XML-RPC Service

Jun 28th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3. include '/home/wceren/private_html/config.inc';
  4. include '/home/wceren/private_html/functions.php';
  5. require_once 'XML/RPC2/Client.php';
  6.  
  7. $client = XML_RPC2_Client::create('http://master/spoa.py/');
  8. $raw =  $client->getGraph('1');
  9.  
  10.  
  11. # Connect to PDO Sqlite Persistent mode
  12. $dbh = new PDO($DBASEURI, null, null, array(PDO::ATTR_PERSISTENT => true));
  13. $fech = '20120627';
  14. $hour = '12';
  15. $min = '00';
  16. $uid = 'test';
  17. $tipcorrida = '1';
  18. $region = 'car';
  19. $cordx = '-82.08';
  20. $cordy = '13.75';
  21. $var1 = '0';
  22. $fuent = '6';
  23. $fechora = sqdatetime($fech, $hour, $min); //Convierte la hora en formato DATETIME para sqlite
  24. $stmt = $dbh->prepare("INSERT INTO corridas (username,tipo,region,fecha,long,lat,radio,objfte,graph) VALUES (?,?,?,?,?,?,?,?,?);");
  25. //$vars = array($uid, $tipcorrida, $region, $fechora, $cordx, $cordy, $var1, $fuent);
  26. // var_dump($vars);
  27. $stmt->bindParam(1, $uid);
  28. $stmt->bindParam(2, $tipcorrida);
  29. $stmt->bindParam(3, $region);
  30. $stmt->bindParam(4, $fechora);
  31. $stmt->bindParam(5, $cordx);
  32. $stmt->bindParam(6, $cordy);
  33. $stmt->bindParam(7, $var1);
  34. $stmt->bindParam(8, $fuent);
  35. $stmt->bindParam(9, $raw->scalar, PDO::PARAM_LOB);
  36. $stmt->execute();
  37. $stmt = null;
  38. $stmt = $dbh->prepare("SELECT last_insert_rowid()");
  39. $stmt->execute();
  40. $rowid = $stmt->fetch();
  41. echo $rowid[0];
  42. $stmt = null;
  43.  
  44. /*var_dump($raw);
  45. $file = "upload.png";
  46. $fh = @fopen($file, "wb");
  47. @fwrite($fh, $raw->scalar);
  48. @fclose($fh);*/
  49. $client->remGraph();    // Remove all graphics files (.png) into master.area51
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment