radityakurnianto

images

Jun 15th, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2. /*connect to host*/
  3. $connect = oci_connect('system','radit','localhost/XE');
  4.  
  5. $response = array();
  6.  
  7. if($connect)
  8. {
  9.     if(isset($_POST["title"]) && isset($_POST["images"]))
  10.     {
  11.         $title = $_POST["title"];
  12.         $image = $_POST["images"];
  13.        
  14.         $query = "INSERT INTO images (TITLE, IMAGES) VALUES (:title, EMPTY_BLOB()) RETURNING field_lob_a INTO :LOB_A";
  15.         $parse = oci_parse($connect, $query);
  16.        
  17.         $lob_a = oci_new_descriptor($connect, OCI_D_LOB);
  18.        
  19.         oci_bind_by_name($parse, ":title", $title);
  20.         oci_bind_by_name($parse, ":LOB_A", $lob_a, -1, OCI_B_BLOB);
  21.        
  22.         if(!oci_execute($parse, OCI_DEFAULT))
  23.         {
  24.             $lob_a->save($lob_date_a);
  25.             oci_commit($connect);
  26.             $lob_a->free();
  27.             $response["code"] = 1;
  28.             $response["message"] = "Success";
  29.             echo json_encode($response);
  30.         }
  31.         else
  32.         {
  33.             $response["code"] = 0;
  34.             $response["message"] = "Failed! Can not insert query";
  35.             echo json_encode($response);
  36.         }
  37.     }
  38.     else
  39.     {
  40.         $response["code"] = 0;
  41.         $response["message"] = "No parameter passed";
  42.         echo json_encode($response);
  43.     }
  44. }
  45. else
  46. {
  47.     $response["code"] = 0;
  48.     $response["message"] = "Can not connect to host";
  49.     echo json_encode($response);
  50. }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment