/**
  * 
  * 
  * @param string $ps_source MySQL URL
  * @param array $pa_options
  * @return bool
  */
 public function read($ps_source, $pa_options = null)
 {
     parent::read($ps_source, $pa_options);
     # http://username:password@hostname/path/table?t=q=query
     $va_url = parse_url($ps_source);
     $va_path = explode("/", $va_url['path']);
     $this->ops_table = $vs_table = array_pop($va_path);
     $vs_path = join("/", $va_path);
     $this->opa_row_ids = array();
     $this->opn_current_row = 0;
     try {
         $this->opo_client = new Client("http://" . $va_url['user'] . ":" . $va_url['pass'] . "@" . $va_url['host'] . ($vs_path ? "/" . $vs_path : ""));
         $request = $this->opo_client->get("/service.php/find/{$vs_table}?" . $va_url['query']);
         $response = $request->send();
         $data = $response->json();
         if (isset($data['ok']) && $data['ok'] == 1 && is_array($data['results'])) {
             foreach ($data['results'] as $vn_i => $va_result) {
                 $this->opa_row_ids[] = $va_result['id'];
             }
         }
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
예제 #2
0
 /**
  * 
  * 
  * @param string $ps_source MySQL URL
  * @param array $pa_options
  * @return bool
  */
 public function read($ps_source, $pa_options = null)
 {
     parent::read($ps_source, $pa_options);
     # mysql://username:password@localhost/database?table=tablename
     # or limit the query using
     # mysql://username:password@localhost/database?table=tablename&limit=100&offset=10
     $va_url = parse_url($ps_source);
     try {
         $vs_db = substr($va_url['path'], 1);
         $this->opo_handle = new Db(null, array("username" => $va_url['user'], "password" => $va_url['pass'], "host" => $va_url['host'], "database" => $vs_db, "type" => 'mysql'));
         $this->opn_current_row = 0;
         parse_str($va_url['query'], $va_path);
         $this->ops_table = $va_path['table'];
         if (!$this->ops_table) {
             return false;
         }
         $vn_limit = caGetOption('limit', $va_path, 0, array('castTo' => 'int'));
         $vn_offset = caGetOption('offset', $va_path, 0, array('castTo' => 'int'));
         $vs_limit = $vn_limit ? " LIMIT " . ($vn_offset ? "{$vn_offset}, {$vn_limit}" : $vn_limit) : "";
         $this->opo_rows = $this->opo_handle->query("SELECT * FROM {$this->ops_table}{$vs_limit}");
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
예제 #3
0
 /**
  * 
  * 
  * @param string $ps_source
  * @param array $pa_options
  * @return bool
  */
 public function read($ps_source, $pa_options = null)
 {
     parent::read($ps_source, $pa_options);
     $vs_path_to_exif_tool = caGetExternalApplicationPath("exiftool");
     $this->opn_current_row = -1;
     $this->opa_row_buf = caMakeArrayKeysLowercase(caExtractMetadataWithExifTool($ps_source));
     if (!is_array($this->opa_row_buf)) {
         return false;
     }
     return true;
 }
예제 #4
0
 /**
  * 
  * 
  * @param string $ps_source
  * @param array $pa_options Options include
  *		dataset = number of worksheet to read [Default=0]
  * @return bool
  */
 public function read($ps_source, $pa_options = null)
 {
     parent::read($ps_source, $pa_options);
     try {
         $this->opo_handle = PHPExcel_IOFactory::load($ps_source);
         $this->opo_handle->setActiveSheetIndex(caGetOption('dataset', $pa_options, 0));
         $o_sheet = $this->opo_handle->getActiveSheet();
         $this->opo_rows = $o_sheet->getRowIterator();
         $this->opn_current_row = 0;
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
예제 #5
0
 /**
  * 
  * 
  * @param string $ps_source
  * @param array $pa_options
  * @return bool
  */
 public function read($ps_source, $pa_options = null)
 {
     parent::read($ps_source, $pa_options);
     try {
         $this->opo_handle = new File_MARC($ps_source, File_MARC::SOURCE_FILE);
         $this->opn_current_row = -1;
         $this->opa_rows = array();
         while ($o_row = $this->opo_handle->next()) {
             $this->opa_rows[] = $o_row;
         }
     } catch (Exception $e) {
         print $e->getMessage();
         return false;
     }
     return true;
 }
 /**
  * 
  * 
  * @param string $ps_source
  * @param array $pa_options
  * @return bool
  */
 public function read($ps_source, $pa_options = null)
 {
     parent::read($ps_source, $pa_options);
     if ($ps_base_path = caGetOption('basePath', $pa_options, null)) {
         $va_tmp = explode("/", $ps_base_path);
         $this->ops_base_root_tag = array_pop($va_tmp);
         $this->ops_xpath = $this->_convertXPathExpression($ps_base_path);
     }
     if (!($this->opo_xml = @DOMDocument::load($ps_source))) {
         return false;
     }
     try {
         $this->opo_xpath = new DOMXPath($this->opo_xml);
     } catch (Exception $e) {
         return false;
     }
     if ($this->ops_xml_namespace_prefix && $this->ops_xml_namespace) {
         $this->opo_xpath->registerNamespace($this->ops_xml_namespace_prefix, $this->ops_xml_namespace);
     }
     $this->opo_handle = $this->opo_xpath->query($this->ops_xpath, null, $this->opb_register_root_tag);
     $this->opn_current_row = 0;
     return $this->opo_handle ? true : false;
 }
 /**
  * 
  * 
  * @param string $ps_source
  * @param array $pa_options
  * @return bool
  */
 public function read($ps_source, $pa_options = null)
 {
     parent::read($ps_source, $pa_options);
     $this->opn_current_row = 0;
     if ($this->opo_parser->parse($ps_source)) {
         $r_f = fopen($ps_source, 'rb');
         $this->opn_num_rows = 0;
         while (!feof($r_f)) {
             $this->opn_num_rows += substr_count(fread($r_f, 8192), "\n");
         }
         fclose($r_f);
         $this->ops_source = $ps_source;
         return true;
     }
     $this->ops_source = null;
     return false;
 }