m0n0lithic

PHP PDO::sqlite3 BLOB with XML-RPC Service (v.2)

Jun 28th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 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. if ( $raw != 0 )
  12. {
  13.         # Connect to PDO Sqlite Persistent mode
  14.        $dbh = new PDO($DBASEURI, null, null, array(PDO::ATTR_PERSISTENT => true));
  15.         $fech = '20120627';
  16.         $hour = '12';
  17.         $min = '00';
  18.         $uid = 'test';
  19.         $tipcorrida = '1';
  20.         $region = 'car';
  21.         $cordx = '-82.08';
  22.         $cordy = '13.75';
  23.         $var1 = '0';
  24.         $fuent = '6';
  25.         $fechora = sqdatetime($fech, $hour, $min); //Convierte la hora en formato DATETIME para sqlite
  26.         $stmt = $dbh->prepare("INSERT INTO corridas (username,tipo,region,fecha,long,lat,radio,objfte,graph) VALUES (?,?,?,?,?,?,?,?,?);");
  27.         //$vars = array($uid, $tipcorrida, $region, $fechora, $cordx, $cordy, $var1, $fuent);
  28.         // var_dump($vars);
  29.         $stmt->bindParam(1, $uid);
  30.         $stmt->bindParam(2, $tipcorrida);
  31.         $stmt->bindParam(3, $region);
  32.         $stmt->bindParam(4, $fechora);
  33.         $stmt->bindParam(5, $cordx);
  34.         $stmt->bindParam(6, $cordy);
  35.         $stmt->bindParam(7, $var1);
  36.         $stmt->bindParam(8, $fuent);
  37.         $stmt->bindParam(9, $raw->scalar, PDO::PARAM_LOB);
  38.         $stmt->execute();
  39.         $stmt = null;
  40.         $stmt = $dbh->prepare("SELECT last_insert_rowid()");
  41.         $stmt->execute();
  42.         $rowid = $stmt->fetch();
  43.         echo $rowid[0];
  44.         $stmt = null;
  45.         $ret = $client->remGraph();     // Remove all graphics files (.png) into master.area51
  46. } else {
  47.         echo "El cluster no generĂ³ grafica para esta corrida.";
  48. }
  49.  
  50. /*var_dump($raw);
  51. $file = "upload.png";
  52. $fh = @fopen($file, "wb");
  53. @fwrite($fh, $raw->scalar);
  54. @fclose($fh);*/
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment