/** * * @param drealtyConnectionEntity $connection * @param drealtyRetsResource $resource * @param drealtyRetsClass $class * @param string $query * @return int */ function fetch_listings_offset_supported_default(drealtyConnectionEntity $connection, $resource, $class, $query) { $offset = 0; $count = 0; $rets = $this->dc->rets; $limit = $class->chunk_size; if ($limit == 0) { $limit = 'NONE'; } $count = 0; $this->dc->rets->SetParam("offset_support", TRUE); if ($this->dc->connect($connection->conid)) { // prepare the query $q = implode('),(', $query); $result = db_select('drealty_field_mappings', 'dfm')->fields('dfm')->condition('conid', $connection->conid)->condition('cid', $class->cid)->execute()->fetchAllAssoc('systemname'); $fields = $this->get_fields($connection->conid, $class->cid); if ($class->process_images) { $fields .= ',' . $class->photo_timestamp_field; } $optional_params = array('Format' => 'COMPACT-DECODED', 'Limit' => "{$limit}"); // do the actual search $search = $rets->SearchQuery($resource->systemname, $class->systemname, "({$q})", $optional_params); // loop through the search results if ($rets->NumRows() > 0) { while ($listing = $rets->FetchRow($search)) { // calculate the hash $listing['hash'] = $this->calculate_hash($listing, $connection, $class); $this->queue->createItem($listing); drush_log("Resource: {$resource->systemname} Class: {$class->systemname} - Queuing Item {$count}"); $count++; } } if ($error = $rets->Error()) { drush_log(dt("drealty encountered an error: (Type: @type Code: @code Msg: @text)", array("@type" => $error['type'], "@code" => $error['code'], "@text" => $error['text']), 'error')); } $rets->FreeResult($search); $this->dc->disconnect(); // do some cleanup unset($items); if ($rets->NumRows() > 0) { return TRUE; } else { return FALSE; } } else { $error = $rets->Error(); watchdog('drealty', "drealty encountered an error: (Type: @type Code: @code Msg: @text)", array("@type" => $error['type'], "@code" => $error['code'], "@text" => $error['text']), WATCHDOG_ERROR); drush_log(dt("drealty encountered an error: (Type: @type Code: @code Msg: @text)", array("@type" => $error['type'], "@code" => $error['code'], "@text" => $error['text']), 'error')); return FALSE; } return FALSE; }
public function createItem($data) { return $this->backend->createItem($data); }