!< store result or last operation
968081
public function query($sql){
		LogMaster::log($sql);

		$res=$this->connection->query($sql);		
		if ($res===false) {
			throw new Exception("CI - sql execution failed");
		}

		if (is_object($res))
			return new PHPCIResultSet($res);
		return new ArrayQueryWrapper(array());
	}
614647
function resultRaw (results) {
    // throw error if results required and not retrieved
    if (this.args.required && !results.length) {
        // throw error
        throw this.error('no records found')
    }
    // if only ids were selected the return result object to fetch records
    if (this.select.isSelectOnlyIds) {
        // build result object
        var result = new ImmutableCoreModelResult({
            query: this,
            results: results,
        })
        // return result or all records if specified
        return this.args.all ? result.all() : result
    }
    // otherwise return ImmutableCoreModelInstance record(s)
    else {
        // query is for a single record
        if (this.args.limit === 1) {
            // return new instance or undefined
            return results.length
                ? this.newInstance(results[0])
                : undefined
        }
        // query is for multiple records
        else {
            return _.map(results, result => this.newInstance(result))
        }
    }
}
280603
async function prevQuote(store) {
  await store.update(state => {
    state.quoteId = state.quoteId - 1
    if (state.quoteId <= 0) {
      state.quoteId = MAX_QUOTE_ID
    }
  })
}
306964
function cacheResults (results) {
    // get current max record number
    return this.cache.model.maxRecordNumber({
        session: this.query.session,
    }).then(n => {
        // if state has changed do not cache
        if (n !== this.initialMaxRecordNumber) {
            return
        }
        // JSON encode data to cache
        try {
            var cacheValue = JSON.stringify({
                n: n,
                v: results,
            })
        }
        catch (err) {
            // ignore errors
        }
        // cache result
        if (cacheValue) {
            debug('view:select:collection:set', this.selectCacheKey)
            return this.cache.redis.setAsync(this.selectCacheKey, cacheValue)
        }
    })
}
374314
def record_result(addr:, client:, data:, task:)
      db[:results] << addr.to_h.merge(client_id: client.id, data: data,
                                      id: UUID.new, received_at: Time.now.utc,
                                      task_id: task.id)
    end
291284
def fetch(key, parameters = {}, conditions = {}, &blk)
      read(key, parameters) ||
        @stores.capture_first {|s| s.fetch(key, parameters, conditions, &blk)} ||
        blk.call
    end
605115
function fetchRowsFromResult(options, statement, context)
{
  var numInterrupts = 0;

  // forward to the result to get a FetchRowsOperation object
  var operation = context.result.fetchRows(options);

  // subscribe to the operation's 'complete' event
  operation.on('complete', function(err, continueCallback)
  {
    // we want to retry if the error is retryable and the
    // result stream hasn't been closed too many times
    if (Errors.isLargeResultSetError(err) && err.response &&
        (err.response.statusCode === 403) &&
        (numInterrupts <
        context.connectionConfig.getResultStreamInterrupts()))
    {
      // increment the interrupt counter
      numInterrupts++;

      // issue a request to fetch the result again
      sendRequestPostExec(context, function(err, body)
      {
        // refresh the result
        context.onStatementRequestComp(err, body);

        // if there was no error, continue from where we got interrupted
        if (!err)
        {
          continueCallback();
        }
      });
    }
    else
    {
      endFetchRows(options, statement, context);
    }
  });
}
354162
def on_success(&block)
      on do |_, value, reason|
        block.call(value) unless reason
      end
    end
995304
def store(self, deferred_result):
        
        self._counter += 1
        self._stored[self._counter] = deferred_result
        return self._counter
589573
function getResult (err) {
        var res = {
            valid: true,
            errors: []
        };

        if (err !== null) {
            res.valid = false;
            res.errors.push(err);
        }

        return res;
    }
1218197
def store_result_in_db(self, result, always_cache=True):
        """"""
        job = self[result.key]

        def extend_dependent_links():
            with self.lock:
                new_workflow_id = id(get_workflow(result.value))
                self.links[new_workflow_id].extend(
                    self.links[id(job.workflow)])
                del self.links[id(job.workflow)]

        def store_result(status):
            result_value_msg = self.registry.to_json(result.value)
            with self.lock:
                self.cur.execute(
                    'update "jobs" set "result" = ?, '
                    '"status" = ? where "id" = ?;',
                    (result_value_msg, status, result.key))

        def acquire_links():
            with self.lock:
                linked_keys = tuple(self.links[id(job.workflow)])
                del self.links[id(job.workflow)]

                # update links for jobs up in the call-stack (parent workflows)
                n_questions = ','.join('?' * len(linked_keys))
                self.cur.execute(
                    'update "jobs" set "link" = ? where "id" in ({});'
                    .format(n_questions),
                    (result.key,) + linked_keys)

                # jobs that were attached to the parent workflow(s) will not
                # receive the current result automatically, so we need to force
                # feed them to the scheduler.
                attached_keys = ()
                for k in linked_keys:
                    attached_keys += tuple(self.attached[k])
                    del self.attached[k]

            return attached_keys

        # if the returned job is not set to be stored, but a parent job
        # is, we still need to store the result.
        if 'store' not in job.hints and not always_cache:
            if job.is_root_node and id(job.workflow) in self.links:
                if is_workflow(result.value):
                    extend_dependent_links()
                    return ()
                else:
                    store_result(Status.LINKEE)
                    return acquire_links()
            else:
                return ()

        # if the return value is a workflow, store the workflow, and add
        # links to this job, to be updated when the resolved result comes in
        if is_workflow(result.value):
            store_result(Status.WORKFLOW)
            with self.lock:
                self.links[id(get_workflow(result.value))].append(result.key)
            if job.is_root_node:
                extend_dependent_links()
            return ()

        store_result(Status.STORED)
        with self.lock:
            attached_keys = tuple(self.attached[result.key])
            del self.attached[result.key]

        if job.is_root_node:
            attached_keys += acquire_links()

        return attached_keys
402279
private void storeResult( double[] result2, int[] id ) throws SchemaException {
        outData = new HashMap<Integer, double[]>();
        for( int i = 0; i < result2.length; i++ ) {
            outData.put(id[i], new double[]{checkResultValue(result2[i])});
        }
    }
928296
function endFetchRows(options, statement, context)
{
  options.end(Errors.externalize(context.resultError), statement);
}
1310232
function log(key, result, done) {
    var storage = this;
    
    // store result as JSON serialized string
    result = JSON.stringify(result);

    // generate result key from task key
    key = key + "-result";
    
    // first add the key to the log
    this.redis().rpush(this.logKey(), key, function(err) {
        if (err) done(err);

        // now store result data
        else storage.redis().set(key, result, done);
    });
}
647048
function (query, callback) {
    if (!callback) {
      callback = query;
      query = null;
    }

    if (typeof query === 'string') {
      query = { aggregateId: query };
    }

    var self = this;

    this.store.getLastEvent(query, function (err, evt) {
      if (err) return callback(err);

      callback(null, new EventStream(self, query, evt ? [evt] : []));
    });
  }
848310
function mergeBatchResults(ordered, batch, bulkResult, err, result) {
  // If we have an error set the result to be the err object
  if (err) {
    result = err;
  } else if (result && result.result) {
    result = result.result;
  } else if (result == null) {
    return;
  }

  // Do we have a top level error stop processing and return
  if (result.ok === 0 && bulkResult.ok === 1) {
    bulkResult.ok = 0;

    const writeError = {
      index: 0,
      code: result.code || 0,
      errmsg: result.message,
      op: batch.operations[0]
    };

    bulkResult.writeErrors.push(new WriteError(writeError));
    return;
  } else if (result.ok === 0 && bulkResult.ok === 0) {
    return;
  }

  // Deal with opTime if available
  if (result.opTime || result.lastOp) {
    const opTime = result.lastOp || result.opTime;
    let lastOpTS = null;
    let lastOpT = null;

    // We have a time stamp
    if (opTime && opTime._bsontype === 'Timestamp') {
      if (bulkResult.lastOp == null) {
        bulkResult.lastOp = opTime;
      } else if (opTime.greaterThan(bulkResult.lastOp)) {
        bulkResult.lastOp = opTime;
      }
    } else {
      // Existing TS
      if (bulkResult.lastOp) {
        lastOpTS =
          typeof bulkResult.lastOp.ts === 'number'
            ? Long.fromNumber(bulkResult.lastOp.ts)
            : bulkResult.lastOp.ts;
        lastOpT =
          typeof bulkResult.lastOp.t === 'number'
            ? Long.fromNumber(bulkResult.lastOp.t)
            : bulkResult.lastOp.t;
      }

      // Current OpTime TS
      const opTimeTS = typeof opTime.ts === 'number' ? Long.fromNumber(opTime.ts) : opTime.ts;
      const opTimeT = typeof opTime.t === 'number' ? Long.fromNumber(opTime.t) : opTime.t;

      // Compare the opTime's
      if (bulkResult.lastOp == null) {
        bulkResult.lastOp = opTime;
      } else if (opTimeTS.greaterThan(lastOpTS)) {
        bulkResult.lastOp = opTime;
      } else if (opTimeTS.equals(lastOpTS)) {
        if (opTimeT.greaterThan(lastOpT)) {
          bulkResult.lastOp = opTime;
        }
      }
    }
  }

  // If we have an insert Batch type
  if (batch.batchType === INSERT && result.n) {
    bulkResult.nInserted = bulkResult.nInserted + result.n;
  }

  // If we have an insert Batch type
  if (batch.batchType === REMOVE && result.n) {
    bulkResult.nRemoved = bulkResult.nRemoved + result.n;
  }

  let nUpserted = 0;

  // We have an array of upserted values, we need to rewrite the indexes
  if (Array.isArray(result.upserted)) {
    nUpserted = result.upserted.length;

    for (let i = 0; i < result.upserted.length; i++) {
      bulkResult.upserted.push({
        index: result.upserted[i].index + batch.originalZeroIndex,
        _id: result.upserted[i]._id
      });
    }
  } else if (result.upserted) {
    nUpserted = 1;

    bulkResult.upserted.push({
      index: batch.originalZeroIndex,
      _id: result.upserted
    });
  }

  // If we have an update Batch type
  if (batch.batchType === UPDATE && result.n) {
    const nModified = result.nModified;
    bulkResult.nUpserted = bulkResult.nUpserted + nUpserted;
    bulkResult.nMatched = bulkResult.nMatched + (result.n - nUpserted);

    if (typeof nModified === 'number') {
      bulkResult.nModified = bulkResult.nModified + nModified;
    } else {
      bulkResult.nModified = null;
    }
  }

  if (Array.isArray(result.writeErrors)) {
    for (let i = 0; i < result.writeErrors.length; i++) {
      const writeError = {
        index: batch.originalZeroIndex + result.writeErrors[i].index,
        code: result.writeErrors[i].code,
        errmsg: result.writeErrors[i].errmsg,
        op: batch.operations[result.writeErrors[i].index]
      };

      bulkResult.writeErrors.push(new WriteError(writeError));
    }
  }

  if (result.writeConcernError) {
    bulkResult.writeConcernErrors.push(new WriteConcernError(result.writeConcernError));
  }
}
365261
def result
      if @cache[:checks].new_objects?
        @cache[:checks].stored_objects.each do |c|
          @result = Result.new(c.sample) unless c.success?
        end
      end

      @result
    end