sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function getFromEntityByIds(string $entityFrom, array $entityIds, array $filterParams = [])
{
$uriAppend = "from/{$entityFrom}";
$params = ['entityIds' => implode(",", $entityIds)];
if ($filterParams) {
$params['params'] = json_encode([$filterParams]);
}
$response = $this->handler->handle('GET', false, $uriAppend, $params)->getData();
if (!$response) {
return [];
}
$functionalNames = [];
if (isset($filterParams['functionalNames']) && $filterParams['functionalNames']) {
$functionalNames = $filterParams['functionalNames'];
}
return $this->client->elastic()
->search($this->prepareElasticSearchBody($response, ['functionalNameId' => $functionalNames]))
->all();
} | @param string $entityFrom
@param array $entityIds
@param array $filterParams
@return array|int|Entity|Collection
@throws \GuzzleHttp\Exception\GuzzleException | entailment |
private function prepareElasticSearchBody(array $data, array $params = []): BodyBuilder
{
$entityWeights = [];
$indexes = [];
foreach (array_column($data, 'attributes') as $correlation) {
$entityCodeInSingular = $correlation['type'];
if (substr($entityCodeInSingular, -1, 1) == 's') {
$entityCodeInSingular = substr($correlation['type'], 0, -1);
}
$className = "SphereMall\\MS\\Entities\\" . ucfirst($entityCodeInSingular);
if (class_exists($className)) {
$indexes[$entityCodeInSingular] = $className;
}
$entityWeights[$correlation['type']][$correlation[$entityCodeInSingular . 'Id']] = doubleval($correlation['value']);
}
$mustQueries = [];
foreach ($entityWeights as $entity => $weights) {
$mustQueries[] = new MustQuery([
new TermQuery('_type', $entity),
new TermsQuery('_id', array_keys($weights)),
]);
}
$mustQuery = [
new TermQuery('visible', 1),
new ShouldQuery($mustQueries),
];
if (isset($params['functionalNameId']) && $params['functionalNameId']) {
$mustQuery[] = new TermsQuery('functionalNameId', $params['functionalNameId']);
}
$mustQuery = new MustQuery($mustQuery);
$body = new BodyBuilder();
$query = (new QueryBuilder())->setMust($mustQuery);
$script = (new DynamicFactors($entityWeights))->getAlgorithm();
$sort[] = new SortElement('_script', 'desc', [
'type' => 'number',
'script' => $script,
]);
return $body->query($query)
->limit($this->limit)
->offset($this->offset)
->sort(new SortBuilder($sort))
->indexes(ElasticSearchIndexHelper::getIndexesByClasses($indexes));
} | @param array $data
@param array $params
@return BodyBuilder | entailment |
public function next()
{
$row = $this->getRow($this->pointer);
if (!is_null($row)) {
$this->pointer++;
}
} | Move forward to next element
@link http://php.net/manual/en/iterator.next.php
@return void Any returned value is ignored.
@since 5.0.0 | entailment |
protected function doValidate($input)
{
if (!$this->isString($input)) {
$this->addError('notString');
return false;
}
$len = strlen($input);
if ($len != 15 && $len != 18) {
$this->addError('invalid');
return false;
}
// Upgrade to 18-digit
if ($len == 15) {
$input = substr($input, 0, 6) . '19' . substr($input, 6);
}
// The 1 to 17-digit must be digit
if (!preg_match('/^([0-9]+)$/', substr($input, 0, -1))) {
$this->addError('invalid');
return false;
}
// Verify date of birth
$month = substr($input, 10, 2);
$day = substr($input, 12, 2);
$year = substr($input, 6, 4);
if (!checkdate($month, $day, $year)) {
$this->addError('invalid');
return false;
}
// Verify checksum
if (isset($input[17])) {
$checksum = $this->calcChecksum($input);
if (strtoupper($input[17]) !== $checksum) {
$this->addError('invalid');
return false;
}
}
return true;
} | {@inheritdoc} | entailment |
public function calcChecksum($input)
{
$wi = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
$sum = 0;
for ($i = 16; $i >= 0; $i--) {
$sum += $input[$i] * $wi[$i];
}
$checksum = (12 - $sum % 11) % 11;
return $checksum == 10 ? 'X' : (string)$checksum;
} | Calculate the final digit of id card
@param string $input The 17 or 18-digit code
@return string | entailment |
protected function doValidate($input)
{
if (!$this->isString($input)) {
$this->addError('notDivisible');
return false;
}
if (is_float($this->divisor)) {
$result = fmod($input, $this->divisor);
} else {
$result = $input % $this->divisor;
}
if (0 != $result) {
$this->addError('notDivisible');
return false;
}
return true;
} | {@inheritdoc} | entailment |
public function toArray($returnFields = array())
{
if (!$this->isColl) {
$data = array_fill_keys($returnFields ?: $this->getFields(), null);
if (!$returnFields) {
return $this->data + $data;
} else {
$data = array_fill_keys($returnFields, null);
return array_intersect_key($this->data, $data) + $data;
}
} else {
$data = array();
/** @var $record Record */
foreach ($this->data as $key => $record) {
$data[$key] = $record->toArray($returnFields);
}
return $data;
}
} | Returns the record data as array
@param array $returnFields A indexed array specified the fields to return
@return array | entailment |
public function fromArray($data)
{
foreach ($data as $key => $value) {
if (is_int($key) || $this->isFillable($key)) {
$this->set($key, $value);
}
}
return $this;
} | Import a PHP array in this record
@param array|\ArrayAccess $data
@return $this | entailment |
public function isFillable($field)
{
return !in_array($field, $this->guarded) && !$this->fillable || in_array($field, $this->fillable);
} | Check if the field is assignable through fromArray method
@param string $field
@return bool | entailment |
public function setData($data)
{
foreach ($data as $field => $value) {
$this->set($field, $value);
}
return $this;
} | Import a PHP array in this record
@param array|\ArrayAccess $data
@return $this | entailment |
public function save($data = array())
{
// 1. Merges data from parameters
$data && $this->fromArray($data);
// 2.1 Saves single record
if (!$this->isColl) {
// 2.1.1 Returns when record has been destroy to avoid store dirty data
if ($this->isDestroyed) {
return $this;
}
// Deletes the record when it's waiting to remove from database
if ($this->detached) {
$this->db->delete($this->table, array($this->primaryKey => $this->data[$this->primaryKey]));
$this->isDestroyed = true;
return $this;
}
// 2.1.2 Triggers before callbacks
$isNew = $this->isNew;
$this->triggerCallback('beforeSave');
$this->triggerCallback($isNew ? 'beforeCreate' : 'beforeUpdate');
// 2.1.3.1 Inserts new record
if ($isNew) {
// Removes primary key value when it's empty to avoid SQL error
if (array_key_exists($this->primaryKey, $this->data) && !$this->data[$this->primaryKey]) {
unset($this->data[$this->primaryKey]);
}
$this->db->insert($this->table, $this->data);
$this->isNew = false;
// Receives primary key value when it's empty
if (!isset($this->data[$this->primaryKey]) || !$this->data[$this->primaryKey]) {
// Prepare sequence name for PostgreSQL
$sequence = sprintf('%s_%s_seq', $this->fullTable, $this->primaryKey);
$this->data[$this->primaryKey] = $this->db->lastInsertId($sequence);
}
// 2.1.3.2 Updates existing record
} else {
if ($this->isChanged) {
$data = array_intersect_key($this->data, $this->changedData);
$this->db->update($this->table, $data, array(
$this->primaryKey => $this->data[$this->primaryKey]
));
}
}
// 2.1.4 Reset changed data and changed status
$this->changedData = array();
$this->isChanged = false;
// 2.1.5. Triggers after callbacks
$this->triggerCallback($isNew ? 'afterCreate' : 'afterUpdate');
$this->triggerCallback('afterSave');
// 2.2 Loop and save collection records
} else {
foreach ($this->data as $record) {
$record->save();
}
}
return $this;
} | Save the record or data to database
@param array $data
@return $this | entailment |
public function destroy($conditions = false)
{
$this->andWhere($conditions);
!$this->loaded && $this->loadData(0);
if (!$this->isColl) {
$this->triggerCallback('beforeDestroy');
$this->executeDestroy();
$this->isDestroyed = true;
$this->triggerCallback('afterDestroy');
} else {
foreach ($this->data as $record) {
$record->destroy();
}
}
return $this;
} | Delete the current record and trigger the beforeDestroy and afterDestroy callback
@param mixed $conditions
@return $this | entailment |
public function reload()
{
$this->data = (array)$this->db->select($this->table, array($this->primaryKey => $this->get($this->primaryKey)));
$this->changedData = array();
$this->isChanged = false;
$this->triggerCallback('afterLoad');
return $this;
} | Reload the record data from database
@return $this | entailment |
public function saveColl($data, $extraData = array(), $sort = false)
{
if (!is_array($data)) {
return $this;
}
// 1. Uses primary key as data index
$newData = array();
foreach ($this->data as $key => $record) {
unset($this->data[$key]);
// Ignore default data
if ($record instanceof $this) {
$newData[$record[$this->primaryKey]] = $record;
}
}
$this->data = $newData;
// 2. Removes empty rows from data
foreach ($data as $index => $row) {
if (!array_filter($row)) {
unset($data[$index]);
}
}
// 3. Removes missing rows
$existIds = array();
foreach ($data as $row) {
if (isset($row[$this->primaryKey]) && $row[$this->primaryKey] !== null) {
$existIds[] = $row[$this->primaryKey];
}
}
/** @var $record Record */
foreach ($this->data as $key => $record) {
if (!in_array($record[$this->primaryKey], $existIds)) {
$record->destroy();
unset($this->data[$key]);
}
}
// 4. Merges existing rows or create new rows
foreach ($data as $index => $row) {
if ($sort) {
$row[$sort] = $index;
}
if (isset($row[$this->primaryKey]) && isset($this->data[$row[$this->primaryKey]])) {
$this->data[$row[$this->primaryKey]]->fromArray($row);
} else {
$this[] = $this->db($this->table)->fromArray($extraData + $row);
}
}
// 5. Save and return
return $this->save();
} | Merges data into collection and save to database, including insert, update and delete
@param array $data A two-dimensional array
@param array $extraData The extra data for new rows
@param bool $sort
@return $this | entailment |
public function get($name)
{
// Check if field exists when it is not a collection
if (!$this->isColl && !in_array($name, $this->getFields())) {
throw new \InvalidArgumentException(sprintf(
'Field "%s" not found in record class "%s"',
$name,
get_class($this)
));
}
return isset($this->data[$name]) ? $this->data[$name] : null;
} | Receives the record field value
@param string $name
@throws \InvalidArgumentException When field not found
@return mixed|$this | entailment |
public function set($name, $value = null)
{
$this->loaded = true;
// Set record for collection
if (!$this->data && $value instanceof static) {
$this->isColl = true;
}
if (!$this->isColl) {
if (in_array($name, $this->getFields())) {
$this->changedData[$name] = isset($this->data[$name]) ? $this->data[$name] : null;
$this->data[$name] = $value;
$this->isChanged = true;
}
} else {
if (!$value instanceof static) {
throw new \InvalidArgumentException('Value for collection must be an instance of Wei\Record');
} else {
// Support $coll[] = $value;
if ($name === null) {
$this->data[] = $value;
} else {
$this->data[$name] = $value;
}
}
}
return $this;
} | Set the record field value
@param string $name
@param mixed $value
@throws \InvalidArgumentException
@return $this | entailment |
public function setAll($name, $value)
{
foreach ($this->data as $record) {
$record[$name] = $value;
}
return $this;
} | Set field value for every record in collection
@param string $name
@param mixed $value
@return $this | entailment |
public function getAll($name)
{
$data = array();
foreach ($this->data as $record) {
$data[] = $record[$name];
}
return $data;
} | Return the value of field from every record in collection
@param string $name
@return array | entailment |
public function remove($name)
{
if (!$this->isColl) {
if (array_key_exists($name, $this->data)) {
$this->data[$name] = null;
}
} else {
unset($this->data[$name]);
}
return $this;
} | Remove field value
@param string $name The name of field
@return $this | entailment |
public function getFields()
{
if (empty($this->fields)) {
$this->fields = $this->db->getTableFields($this->fullTable, true);
}
return $this->fields;
} | Returns the name of fields of current table
@return array | entailment |
public function getChangedData($field = null)
{
if ($field) {
return isset($this->changedData[$field]) ? $this->changedData[$field] : null;
}
return $this->changedData;
} | Return the field data before changed
@param string $field
@return string|array | entailment |
public function execute()
{
if ($this->type == self::SELECT) {
$this->loaded = true;
if ($this->cacheTime !== false) {
return $this->fetchFromCache();
} else {
return $this->db->fetchAll($this->getSql(), $this->params, $this->paramTypes);
}
} else {
return $this->db->executeUpdate($this->getSql(), $this->params, $this->paramTypes);
}
} | Execute this query using the bound parameters and their types
@return mixed | entailment |
public function find($conditions = false)
{
$this->isColl = false;
$data = $this->fetch($conditions);
if ($data) {
$this->data = $data + $this->data;
$this->triggerCallback('afterFind');
return $this;
} else {
return false;
}
} | Executes the generated SQL and returns the found record object or false
@param mixed $conditions
@return $this|false | entailment |
public function findOrInit($conditions = false, $data = array())
{
if (!$this->find($conditions)) {
// Reset status when record not found
$this->isNew = true;
!is_array($conditions) && $conditions = array($this->primaryKey => $conditions);
// Convert to object to array
if (is_object($data) && method_exists($data, 'toArray')) {
$data = $data->toArray();
}
// conditions data are fillable
$this->fromArray($data);
$this->setData($conditions);
}
return $this;
} | Find a record by specified conditions and init with the specified data if record not found
@param mixed $conditions
@param array $data
@return $this | entailment |
public function findAll($conditions = false)
{
$this->isColl = true;
$data = $this->fetchAll($conditions);
$records = array();
foreach ($data as $key => $row) {
/** @var $records Record[] */
$records[$key] = $this->db->init($this->table, $row, false);
$records[$key]->triggerCallback('afterFind');
}
$this->data = $records;
return $this;
} | Executes the generated SQL and returns the found record collection object or false
@param mixed $conditions
@return $this|$this[] | entailment |
public function fetch($conditions = false)
{
$this->andWhere($conditions);
$this->limit(1);
$data = $this->execute();
return $data ? $data[0] : false;
} | Executes the generated query and returns the first array result
@param mixed $conditions
@return array|false | entailment |
public function fetchColumn($conditions = false)
{
$data = $this->fetch($conditions);
return $data ? current($data) : false;
} | Executes the generated query and returns a column value of the first row
@param mixed $conditions
@return array|false | entailment |
public function fetchAll($conditions = false)
{
$this->andWhere($conditions);
$data = $this->execute();
if ($this->indexBy) {
$data = $this->executeIndexBy($data, $this->indexBy);
}
return $data;
} | Executes the generated query and returns all array results
@param mixed $conditions
@return array|false | entailment |
public function count($conditions = false, $count = '1')
{
$this->andWhere($conditions);
$select = $this->sqlParts['select'];
$this->select('COUNT(' . $count . ')');
$count = (int)$this->db->fetchColumn($this->getSqlForSelect(true), $this->params);
$this->sqlParts['select'] = $select;
return $count;
} | Executes a COUNT query to receive the rows number
@param mixed $conditions
@param string $count
@return int | entailment |
public function countBySubQuery($conditions = false)
{
$this->andWhere($conditions);
return (int)$this->db->fetchColumn($this->getSqlForCount(), $this->params);
} | Executes a sub query to receive the rows number
@param mixed $conditions
@return int | entailment |
public function update($set = array())
{
if (is_array($set)) {
$params = array();
foreach ($set as $field => $param) {
$this->add('set', $field . ' = ?', true);
$params[] = $param;
}
$this->params = array_merge($params, $this->params);
} else {
$this->add('set', $set, true);
}
$this->type = self::UPDATE;
return $this->execute();
} | Execute a update query with specified data
@param array|string $set
@return int | entailment |
public function delete($conditions = false)
{
$this->andWhere($conditions);
$this->type = self::DELETE;
return $this->execute();
} | Execute a delete query with specified conditions
@param mixed $conditions
@return mixed | entailment |
public function offset($offset)
{
$offset = (int)$offset;
$offset < 0 && $offset = 0;
return $this->add('offset', $offset);
} | Sets the position of the first result to retrieve (the "offset")
@param integer $offset The first result to return
@return $this | entailment |
public function limit($limit)
{
$limit = (int)$limit;
$limit < 1 && $limit = 1;
return $this->add('limit', $limit);
} | Sets the maximum number of results to retrieve (the "limit")
@param integer $limit The maximum number of results to retrieve
@return $this | entailment |
public function page($page)
{
$limit = $this->getSqlPart('limit');
if (!$limit) {
$limit = 10;
$this->add('limit', $limit);
}
return $this->offset(($page - 1) * $limit);
} | Sets the page number, the "OFFSET" value is equals "($page - 1) * LIMIT"
@param int $page The page number
@return $this | entailment |
public function from($from)
{
$pos = strpos($from, ' ');
if (false !== $pos) {
$this->table = substr($from, 0, $pos);
} else {
$this->table = $from;
}
$this->fullTable = $this->db->getTable($this->table);
return $this->add('from', $this->db->getTable($from));
} | Sets table for FROM query
@param string $from The table
@return $this | entailment |
public function where($conditions, $params = array(), $types = array())
{
if ($conditions === false) {
return $this;
} else {
$conditions = $this->processCondition($conditions, $params, $types);
return $this->add('where', $conditions);
}
} | Specifies one or more restrictions to the query result.
Replaces any previously specified restrictions, if any.
```php
$user = wei()->db('user')->where('id = 1');
$user = wei()->db('user')->where('id = ?', 1);
$users = wei()->db('user')->where(array('id' => '1', 'username' => 'twin'));
$users = wei()->where(array('id' => array('1', '2', '3')));
```
@param mixed $conditions The WHERE conditions
@param array $params The condition parameters
@param array $types The parameter types
@return $this | entailment |
public function andWhere($conditions, $params = array(), $types = array())
{
if ($conditions === false) {
return $this;
} else {
$conditions = $this->processCondition($conditions, $params, $types);
return $this->add('where', $conditions, true, 'AND');
}
} | Adds one or more restrictions to the query results, forming a logical
conjunction with any previously specified restrictions
@param string|array $conditions The WHERE conditions
@param array $params The condition parameters
@param array $types The parameter types
@return $this | entailment |
public function orWhere($conditions, $params = array(), $types = array())
{
$conditions = $this->processCondition($conditions, $params, $types);
return $this->add('where', $conditions, true, 'OR');
} | Adds one or more restrictions to the query results, forming a logical
disjunction with any previously specified restrictions.
@param string $conditions The WHERE conditions
@param array $params The condition parameters
@param array $types The parameter types
@return $this | entailment |
public function having($conditions, $params = array(), $types = array())
{
$conditions = $this->processCondition($conditions, $params, $types);
return $this->add('having', $conditions);
} | Specifies a restriction over the groups of the query.
Replaces any previous having restrictions, if any.
@param string $conditions The having conditions
@param array $params The condition parameters
@param array $types The parameter types
@return $this | entailment |
public function andHaving($conditions, $params = array(), $types = array())
{
$conditions = $this->processCondition($conditions, $params, $types);
return $this->add('having', $conditions, true, 'AND');
} | Adds a restriction over the groups of the query, forming a logical
conjunction with any existing having restrictions.
@param string $conditions The HAVING conditions to append
@param array $params The condition parameters
@param array $types The parameter types
@return $this | entailment |
public function orHaving($conditions, $params = array(), $types = array())
{
$conditions = $this->processCondition($conditions, $params, $types);
return $this->add('having', $conditions, true, 'OR');
} | Adds a restriction over the groups of the query, forming a logical
disjunction with any existing having restrictions.
@param string $conditions The HAVING conditions to add
@param array $params The condition parameters
@param array $types The parameter types
@return $this | entailment |
public function indexBy($field)
{
$this->data = $this->executeIndexBy($this->data, $field);
$this->indexBy = $field;
return $this;
} | Specifies a field to be the key of the fetched array
@param string $field
@return $this | entailment |
public function getSqlPart($name)
{
return isset($this->sqlParts[$name]) ? $this->sqlParts[$name] : false;
} | Returns a SQL query part by its name
@param string $name The name of SQL part
@return mixed | entailment |
public function resetSqlParts($name = null)
{
if (is_null($name)) {
$name = array_keys($this->sqlParts);
}
foreach ($name as $queryPartName) {
$this->resetSqlPart($queryPartName);
}
return $this;
} | Reset all SQL parts
@param array $name
@return $this | entailment |
public function resetSqlPart($name)
{
$this->sqlParts[$name] = is_array($this->sqlParts[$name]) ? array() : null;
$this->state = self::STATE_DIRTY;
return $this;
} | Reset single SQL part
@param string $name
@return $this | entailment |
public function getParameter($key)
{
return isset($this->params[$key]) ? $this->params[$key] : null;
} | Gets a (previously set) query parameter of the query being constructed
@param mixed $key The key (index or name) of the bound parameter
@return mixed The value of the bound parameter | entailment |
public function getSql()
{
if ($this->sql !== null && $this->state === self::STATE_CLEAN) {
return $this->sql;
}
switch ($this->type) {
case self::DELETE:
$this->sql = $this->getSqlForDelete();
break;
case self::UPDATE:
$this->sql = $this->getSqlForUpdate();
break;
case self::SELECT:
default:
$this->sql = $this->getSqlForSelect();
break;
}
$this->state = self::STATE_CLEAN;
return $this->sql;
} | Get the complete SQL string formed by the current specifications of this QueryBuilder
@return string The sql query string | entailment |
protected function getSqlForSelect($count = false)
{
$parts = $this->sqlParts;
if (!$parts['select']) {
$parts['select'] = array('*');
}
$query = 'SELECT ' . implode(', ', $parts['select']) . ' FROM ' . $this->getFrom();
// JOIN
foreach ($parts['join'] as $join) {
$query .= ' ' . strtoupper($join['type'])
. ' JOIN ' . $join['table']
. ' ON ' . $join['on'];
}
$query .= ($parts['where'] !== null ? ' WHERE ' . ((string)$parts['where']) : '')
. ($parts['groupBy'] ? ' GROUP BY ' . implode(', ', $parts['groupBy']) : '')
. ($parts['having'] !== null ? ' HAVING ' . ((string)$parts['having']) : '');
if (false === $count) {
$query .= ($parts['orderBy'] ? ' ORDER BY ' . implode(', ', $parts['orderBy']) : '')
. ($parts['limit'] !== null ? ' LIMIT ' . $parts['limit'] : '')
. ($parts['offset'] !== null ? ' OFFSET ' . $parts['offset'] : '');
}
$query .= $this->generateLockSql();
return $query;
} | Converts this instance into an SELECT string in SQL
@param bool $count
@return string | entailment |
protected function getSqlForUpdate()
{
$query = 'UPDATE ' . $this->getFrom()
. ' SET ' . implode(", ", $this->sqlParts['set'])
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string)$this->sqlParts['where']) : '');
return $query;
} | Converts this instance into an UPDATE string in SQL.
@return string | entailment |
public function offsetSet($offset, $value)
{
$this->loadData($offset);
$this->set($offset, $value);
} | Set the offset value
@param string $offset
@param mixed $value | entailment |
protected function add($sqlPartName, $sqlPart, $append = false, $type = null)
{
$this->isNew = false;
if (!$sqlPart) {
return $this;
}
$isArray = is_array($sqlPart);
$isMultiple = is_array($this->sqlParts[$sqlPartName]);
if ($isMultiple && !$isArray) {
$sqlPart = array($sqlPart);
}
$this->state = self::STATE_DIRTY;
if ($append) {
if ($sqlPartName == 'where' || $sqlPartName == 'having') {
if ($this->sqlParts[$sqlPartName]) {
$this->sqlParts[$sqlPartName] = '(' . $this->sqlParts[$sqlPartName] . ') ' . $type . ' (' . $sqlPart . ')';
} else {
$this->sqlParts[$sqlPartName] = $sqlPart;
}
} elseif ($sqlPartName == 'orderBy' || $sqlPartName == 'groupBy' || $sqlPartName == 'select' || $sqlPartName == 'set') {
foreach ($sqlPart as $part) {
$this->sqlParts[$sqlPartName][] = $part;
}
} elseif ($isMultiple) {
$this->sqlParts[$sqlPartName][] = $sqlPart;
}
return $this;
}
$this->sqlParts[$sqlPartName] = $sqlPart;
return $this;
} | Either appends to or replaces a single, generic query part.
The available parts are: 'select', 'from', 'set', 'where',
'groupBy', 'having', 'orderBy', 'limit' and 'offset'.
@param string $sqlPartName
@param string $sqlPart
@param boolean $append
@param string $type
@return $this | entailment |
protected function processCondition($conditions, $params, $types)
{
// Regard numeric and null as primary key value
if (is_numeric($conditions) || empty($conditions)) {
$conditions = array($this->primaryKey => $conditions);
}
if (is_array($conditions)) {
$where = array();
$params = array();
foreach ($conditions as $field => $condition) {
if (is_array($condition)) {
$where[] = $field . ' IN (' . implode(', ', array_pad(array(), count($condition), '?')) . ')';
$params = array_merge($params, $condition);
} else {
$where[] = $field . " = ?";
$params[] = $condition;
}
}
$conditions = implode(' AND ', $where);
}
if ($params !== false) {
if (is_array($params)) {
$this->params = array_merge($this->params, $params);
$this->paramTypes = array_merge($this->paramTypes, $types);
} else {
$this->params[] = $params;
if ($types) {
$this->paramTypes[] = $types;
}
}
}
return $conditions;
} | Generate condition string for WHERE or Having statement
@param mixed $conditions
@param array $params
@param array $types
@return string | entailment |
protected function loadData($offset)
{
if (!$this->loaded && !$this->isNew) {
if (is_numeric($offset) || is_null($offset)) {
$this->findAll();
} else {
$this->find();
}
}
} | Load record by array offset
@param int|string $offset | entailment |
public function filter(\Closure $fn)
{
$data = array_filter($this->data, $fn);
$records = $this->db->init($this->table, array(), $this->isNew);
$records->data = $data;
$records->isColl = true;
$records->loaded = $this->loaded;
return $records;
} | Filters elements of the collection using a callback function
@param \Closure $fn
@return $this | entailment |
public function cache($seconds = null)
{
if ($seconds === null) {
$this->cacheTime = $this->defaultCacheTime;
} elseif ($seconds === false) {
$this->cacheTime = false;
} else {
$this->cacheTime = (int)$seconds;
}
return $this;
} | Set or remove cache time for the query
@param int|null|false $seconds
@return $this | entailment |
public function tags($tags = null)
{
$this->cacheTags = $tags === false ? false : $tags;
return $this;
} | Set or remove cache tags
@param array|null|false $tags
@return $this | entailment |
public function getCacheKey()
{
return $this->cacheKey ?: md5($this->db->getDbname() . $this->getSql() . serialize($this->params) . serialize($this->paramTypes));
} | Generate cache key form query and params
@return string | entailment |
protected function doValidate($input)
{
if (!$this->isString($input)) {
$this->addError('notString');
return false;
}
if (8 != strlen($input)) {
$this->addError('invalid');
return false;
}
$input = strtoupper($input);
// The first char should be A-Z
$first = ord($input[0]);
if ($first < 65 || $first > 90) {
$this->addError('invalid');
return false;
}
// c1 = ord(c1) - 64 => A=1, B=2, ... , Z=26
// sum = c1*8 + c2*7 + ... + c6*3 + c5*2
$sum = ($first - 64) * 8;
for ($i = 1, $j = 7; $i < 7; $i++, $j--) {
$sum += $input[$i] * $j;
}
$checksum = $sum % 11;
if ($checksum == 1) {
$checksum = 'A';
} elseif ($checksum > 1) {
$checksum = 11 - $checksum;
}
if ($checksum != $input[7]) {
$this->addError('invalid');
return false;
}
return true;
} | {@inheritdoc} | entailment |
public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($options['button_groups'] as $name => $config) {
$builder->add($name, ButtonGroupType::class, $config);
}
} | Pull all group of button into the form.
{@inheritdoc} | entailment |
public function execute()
{
try {
// Note that when provided a non-existing WSDL, PHP will still generate an error in error_get_last()
// https://github.com/bcosca/fatfree/issues/404
// https://bugs.php.net/bug.php?id=65779
// Prepare request
$soapClient = $this->soapClient = new SoapClient($this->url, array(
'trace' => $this->wei->isDebug()
));
// Execute beforeExecute and beforeSend callbacks
$this->beforeExecute && call_user_func($this->beforeExecute, $this, $soapClient);
$this->beforeSend && call_user_func($this->beforeSend, $this, $soapClient);
// Execute request
$this->response = $soapClient->__soapCall($this->method, array($this->data));
} catch (\SoapFault $e) {
$soapClient = null;
$this->errorException = $e;
}
// Trigger success, error and complete callbacks
if (!$this->errorException) {
$this->success && call_user_func($this->success, $this->response, $this, $soapClient);
} else {
$this->error && call_user_func($this->error, $this, $soapClient);
}
$this->complete && call_user_func($this->complete, $this, $soapClient);
if ($this->throwException && $this->errorException) {
throw $this->errorException;
}
return $this;
} | Execute the request, parse the response data and trigger relative callbacks | entailment |
public function loadFromFile($pattern)
{
if (isset($this->files[$pattern])) {
return $this;
}
$file = sprintf($pattern, $this->locale);
if (!is_file($file)) {
$defaultFile = sprintf($pattern, $this->defaultLocale);
if (!is_file($defaultFile)) {
throw new \InvalidArgumentException(sprintf('File "%s" and "%s" not found or not readable', $file, $defaultFile));
} else {
$file = $defaultFile;
}
}
$this->files[$pattern] = true;
return $this->loadFromArray(require $file);
} | Loads translator messages from file
@param string $pattern The file path, which can contains %s that would be convert the current locale or fallback locale
@return $this
@throws \InvalidArgumentException When file not found or not readable | entailment |
protected function doValidate($input)
{
if (!is_array($input) && !$input instanceof \Traversable) {
$this->addError('notArray');
return false;
}
$index = 1;
$validator = null;
foreach ($input as $item) {
foreach ($this->rules as $rule => $options) {
if (!$this->validate->validateOne($rule, $item, $options, $validator)) {
$this->validators[$index][$rule] = $validator;
}
}
$index++;
}
// Adds the placeholder message
if (count($this->validators)) {
$this->addError('invalid');
return false;
}
return true;
} | {@inheritdoc} | entailment |
public function getMessages($name = null)
{
$this->loadTranslationMessages();
$translator = $this->t;
// Firstly, translates the item name (%name%'s %index% item)
// Secondly, translates "%name%" in the item name
$name = $translator($translator($this->itemName), array(
'%name%' => $translator($name ?: $this->name)
));
$messages = array();
foreach ($this->validators as $index => $validators) {
/** @var $validator BaseValidator */
foreach ($validators as $rule => $validator) {
// Lastly, translates "index" in the item name
$validator->setName($translator($name, array(
'%index%' => $index
)));
foreach ($validator->getMessages() as $option => $message) {
$messages[$rule . '.' . $option . '.' . $index] = $message;
}
}
}
return $messages;
} | {@inheritdoc} | entailment |
public function assign($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $key => $value) {
$this->object->addGlobal($key, $value);
}
} else {
$this->object->addGlobal($name, $value);
}
return $this;
} | {@inheritdoc} | entailment |
public function onAfterLoadIntoFile($file)
{
// return if not an image
if (!$file->getIsImage()) {
return;
}
// get parent folder path
$folder = rtrim($file->Parent()->getFilename(), '/');
$custom_folders = $this->config()->get('custom_folders');
if (!empty($custom_folders[$folder]) && is_array($custom_folders[$folder])) {
foreach ($custom_folders[$folder] as $key => $val) {
$this->config()->set($key, $val);
}
}
if ($this->config()->get('bypass')) {
return;
}
$this->config_max_width = $this->config()->get('max_width');
$this->config_max_height = $this->config()->get('max_height');
$this->config_auto_rotate = $this->config()->get('auto_rotate');
$this->config_force_resampling = $this->config()->get('force_resampling');
$extension = $file->getExtension();
if ($this->config_force_resampling ||
($this->config_max_height && $file->getHeight() > $this->config_max_height) ||
($this->config_max_width && $file->getWidth() > $this->config_max_width) ||
($this->config_auto_rotate && preg_match('/jpe?g/i', $file->getExtension()))
) {
$this->scaleUploadedImage($file);
}
} | Post data manupulation
@param File
@return Null | entailment |
private function scaleUploadedImage($file)
{
$backend = $file->getImageBackend();
// temporary location for image manipulation
$tmp_image = TEMP_FOLDER . '/resampled-' . mt_rand(100000, 999999) . '.' . $file->getExtension();
$tmp_contents = $file->getString();
// write to tmp file
@file_put_contents($tmp_image, $tmp_contents);
$backend->loadFrom($tmp_image);
if ($backend->getImageResource()) {
$modified = false;
// clone original
$transformed = $backend;
/* If rotation allowed & JPG, test to see if orientation needs switching */
if ($this->config_auto_rotate && preg_match('/jpe?g/i', $file->getExtension())) {
$switch_orientation = $this->exifRotation($tmp_image);
if ($switch_orientation) {
$modified = true;
$transformed->setImageResource($transformed->getImageResource()->orientate());
}
}
// resize to max values
if ($transformed &&
(
($this->config_max_width && $transformed->getWidth() > $this->config_max_width) ||
($this->config_max_height && $transformed->getHeight() > $this->config_max_height)
)
) {
if ($this->config_max_width && $this->config_max_height) {
$transformed = $transformed->resizeRatio($this->config_max_width, $this->config_max_height);
} elseif ($this->config_max_width) {
$transformed = $transformed->resizeByWidth($this->config_max_width);
} else {
$transformed = $transformed->resizeByHeight($this->config_max_height);
}
$modified = true;
} elseif ($transformed && $this->config_force_resampling) {
$modified = true;
}
// write to tmp file and then overwrite original
if ($transformed && $modified) {
$transformed->writeTo($tmp_image);
// if !legacy_filenames then delete original, else rogue copies are left on filesystem
if (!Config::inst()->get(FlysystemAssetStore::class, 'legacy_filenames')) {
$file->File->deleteFile();
}
$file->setFromLocalFile($tmp_image, $file->FileName); // set new image
$file->write();
}
}
@unlink($tmp_image); // delete tmp file
} | Scale an image
@param File
@return Null | entailment |
private function exifRotation($file)
{
if (!function_exists('exif_read_data')) {
return false;
}
$exif = @exif_read_data($file);
if (!$exif) {
return false;
}
$ort = @$exif['IFD0']['Orientation'];
if (!$ort) {
$ort = @$exif['Orientation'];
}
switch ($ort) {
case 3: // image upside down
return '180';
break;
case 6: // 90 rotate right
return '-90';
break;
case 8: // 90 rotate left
return '90';
break;
default:
return false;
}
} | exifRotation - return the exif rotation
@param String $FileName
@return Int false|angle | entailment |
protected function doValidate($input)
{
if (!$this->isString($input)) {
$this->addError('notString');
return false;
}
if (10 != strlen($input)) {
$this->addError('invalid');
return false;
}
$input = strtoupper($input);
// Validate the city letter, should be A-Z
$first = ord($input[0]);
if ($first < 65 || $first > 90) {
$this->addError('invalid');
return false;
}
// Validate the gender
if ($input[1] != '1' && $input[1] != '2') {
$this->addError('invalid');
return false;
}
list($x1, $x2) = str_split((string)$this->map[$input[0]]);
$sum = $x1 + 9 * $x2;
for ($i = 1, $j = 8; $i < 9; $i++, $j--) {
$sum += $input[$i] * $j;
}
$sum += $input[9];
if (0 !== $sum % 10) {
$this->addError('invalid');
return false;
}
return true;
} | {@inheritdoc} | entailment |
protected function doValidate($input)
{
$this->count = 0;
foreach ($this->fields as $field) {
if ($this->validator->getFieldData($field)) {
$this->count++;
}
}
if (!is_null($this->length) && $this->count != $this->length) {
$this->addError('length');
return false;
}
if (!is_null($this->min) && $this->count < $this->min) {
$this->addError('tooFew');
return false;
}
if (!is_null($this->max) && $this->count > $this->max) {
$this->addError('tooMany');
return false;
}
return true;
} | {@inheritdoc} | entailment |
public function build()
{
return [
'offset' => $this->getOffset(),
'limit' => $this->getLimit(),
'orderBy' => $this->getOrderBy(),
'orderDirection' => $this->getOrderDirection(),
'withFeedbackOnly' => $this->isWithFeedbackOnly(),
'createdFrom' => $this->getCreatedFrom() ? $this->getCreatedFrom()->format(\DateTime::ISO8601) : null,
'createdTill' => $this->getCreatedTill() ? $this->getCreatedTill()->format(\DateTime::ISO8601) : null,
'shopId' => $this->getShopId(),
'customDataFilter' => $this->getCustomDataFilter() ? json_encode($this->getCustomDataFilter()) : null,
];
} | {@inheritdoc} | entailment |
protected function doValidate($input)
{
if (false === ($len = $this->getLength($input))) {
$this->addError('notDetected');
return false;
}
if ($this->max < $len) {
$this->addError(is_scalar($input) ? 'tooLong' : 'tooMany');
return false;
}
return true;
} | {@inheritdoc} | entailment |
protected function doCreateObject(array $array)
{
$this->data = $array;
$this->category = new Category($this->data);
$this->setMedia()
->setAttributes();
return $this->category;
} | @param array $array
@return Category | entailment |
public function full($url, $argsOrParams = array(), $params = array())
{
return $this->request->getUrlFor($this->__invoke($url, $argsOrParams, $params));
} | Generate the absolute URL path by specified URL and parameters
@param string $url
@param string|array $argsOrParams
@param string|array $params
@return string | entailment |
public function query($url = '', $argsOrParams = array(), $params = array())
{
if (strpos($url, '%s') === false) {
$argsOrParams = $argsOrParams + $this->request->getQueries();
} else {
$params += $this->request->getQueries();
}
return $this->__invoke($url, $argsOrParams, $params);
} | Generate the URL path with current query parameters and specified parameters
@param string $url
@param string|array $argsOrParams
@param string|array $params
@return string | entailment |
public function append($url = '', $argsOrParams = array(), $params = array())
{
if (strpos($url, '%s') !== false) {
$url = vsprintf($url, (array)$argsOrParams);
} else {
$params = $argsOrParams;
}
if ($params) {
$url .= (false === strpos($url, '?') ? '?' : '&');
}
return $url . (is_array($params) ? http_build_query($params) : $params);
} | Append parameters to specified URL
@param string $url
@param string|array $argsOrParams The arguments to replace in URL or the parameters append to the URL
@param string|array $params The parameters append to the URL
@return string | entailment |
private function getPart($key) {
if (\array_key_exists($key, $this->content) === false) {
$this->content[$key]=new HtmlTableContent("", $key);
if ($key !== "tbody") {
$this->content[$key]->setRowCount(1, $this->_colCount);
}
}
return $this->content[$key];
} | Returns/create eventually a part of the table corresponding to the $key : thead, tbody or tfoot
@param string $key
@return HtmlTableContent | entailment |
public function addRow($values=array()) {
$row=$this->getBody()->addRow($this->_colCount);
$row->setValues(\array_values($values));
return $this;
} | Adds a new row and sets $values to his cols
@param array $values
@return \Ajax\semantic\html\collections\HtmlTable | entailment |
protected function readAndVerify($handle, $file)
{
$content = $this->getContent($file);
// Check if content is valid
if ($content && is_array($content) && time() < $content[0]) {
return $content;
} else {
return false;
}
} | {@inheritdoc} | entailment |
protected function prepareContent($content, $expire)
{
$time = time();
$content = var_export(array($expire ? $time + $expire : 2147483647, $content), true);
return "<?php\n\nreturn " . $content . ';';
} | {@inheritdoc} | entailment |
public function ap(Monadic $app) : Monadic
{
$list = $this->extract();
$result = compose(
partialLeft(\Chemem\Bingo\Functional\Algorithms\filter, function ($val) {
return is_callable($val);
}),
partialLeft(
\Chemem\Bingo\Functional\Algorithms\map,
function ($func) use ($list) {
$app = function (array $acc = []) use ($func, $list) {
return mapDeep($func, $list);
};
return $app();
}
),
function ($result) use ($list) {
return extend($list, ...$result);
}
);
return new static($result($app->extract()));
} | ap method.
@param object ListMonad
@return object ListMonad | entailment |
public function bind(callable $function) : Monadic
{
$concat = compose(
function (array $list) use ($function) {
return fold(
function ($acc, $item) use ($function) {
$acc[] = $function($item)->extract();
return $acc;
},
$list,
[]
);
},
partialLeft('array_merge', $this->collection)
);
return self::of(flatten($concat($this->collection)));
} | bind method.
@param callable $function
@return object ListMonad | entailment |
public function getHistoryByEntityAndId(string $entity, int $objectId)
{
$params = $this->getQueryParams();
$uriAppend = "$entity/$objectId";
$response = $this->handler->handle('GET', false, $uriAppend, $params);
if (!$response->getSuccess()) {
throw new EntityNotFoundException($response->getErrorMessage());
}
return $this->make($response);
} | @param string $entity
@param int $objectId
@return array|int|\SphereMall\MS\Entities\Entity|\SphereMall\MS\Lib\Collection
@throws EntityNotFoundException
@throws \GuzzleHttp\Exception\GuzzleException | entailment |
public function addHistory(string $entity, int $entityId, array $params = [])
{
$uriAppend = "$entity/$entityId";
$response = $this->handler->handle('POST', $params, $uriAppend);
if (!$response->getSuccess()) {
throw new EntityNotFoundException($response->getErrorMessage());
}
return $this->make($response);
} | @param string $entity
@param int $entityId
@param array $params
@return array|int|\SphereMall\MS\Entities\Entity|\SphereMall\MS\Lib\Collection
@throws EntityNotFoundException
@throws \GuzzleHttp\Exception\GuzzleException | entailment |
public final function setOrderData(Order $order)
{
if (get_called_class() != self::class) {
throw new \InvalidArgumentException("Method can be call only by OrderFinalized entity");
}
$this->id = $order->id;
$this->setProperties($order);
} | #region [Setter] | entailment |
public function update(array $params = [])
{
$params = array_intersect_key(
$params,
array_flip([
'statusId',
'orderId',
'paymentStatusId',
'additionalInfo',
'paymentStatusDescription'
])
);
//Update current order with params
$order = $this->client
->orders($this->client->getVersion())
->update($this->getId(), $params);
//Get order by current orderId with items
$orderWithItems = $this->client->orders($this->client->getVersion())->byId($this->getId());
$order->items = $orderWithItems->items;
//Set data to current order
$this->setOrderData($order);
} | @param array $params
@throws \SphereMall\MS\Exceptions\EntityNotFoundException | entailment |
protected function doValidate($input)
{
parent::doValidate($input);
if ($this->hasError('notString') || $this->hasError('notFound')) {
return false;
}
// Receive the real file path resolved by parent class
$file = $this->file;
$size = @getimagesize($file);
if (false === $size) {
$this->addError('notDetected');
return false;
}
$this->width = $size[0];
$this->height = $size[1];
if ($this->maxWidth && $this->maxWidth < $this->width) {
$this->addError('widthTooBig');
}
if ($this->minWidth && $this->minWidth > $this->width) {
$this->addError('widthTooSmall');
}
if ($this->maxHeight && $this->maxHeight < $this->height) {
$this->addError('heightTooBig');
}
if ($this->minHeight && $this->minHeight > $this->height) {
$this->addError('heightTooSmall');
}
return !$this->errors;
} | {@inheritdoc} | entailment |
private function getParamsFromFilter()
{
if (!$this->body['filter']) {
return [];
}
$result = [];
$must = [];
$mustNot = [];
$params = $this->body['filter']->getParams();
if (isset($params['groupBy']) && $params['groupBy']) {
$result = $this->initGroupBy($params['factorValues'] ?? []);
}
if (isset($params['factorValues']) && $params['factorValues'] && !$this->groupBy) {
$sortEl[] = new SortElement("_script", "desc", [
'type' => "number",
'script' => (new MathSumWithFactor($params['factorValues']))->getAlgorithm(),
]);
$this->body['sort'] = (new SortBuilder($sortEl))->toArray()['sort'];
}
if (isset($params['entities']) && $params['entities']) {
$result['index'] = $params['entities'];
}
if (isset($params['keyword'])) {
$must[] = new MultiMatchQuery($params['keyword']['value'], $params['keyword']['fields']);
}
foreach ($params['params'] ?? [] as $param) {
list($query, $operator) = $param->createFilter();
if ($operator == FilterOperators::IN) {
$must[] = $query;
} else {
$mustNot[] = $query;
}
}
if ($mustNot || $must) {
$query = new QueryBuilder();
if ($mustNot) {
$query->setMustNot(new MustNotQuery($mustNot));
}
if ($must) {
$query->setMust(new MustQuery($must));
}
$result['body']['query'] = $query->toArray();
}
return $result;
} | @param $filter
@return array | entailment |
private function initGroupBy($factorValues = [])
{
$this->groupBy = true;
$params['body']['size'] = 0;
$size = $this->body['size'] ? $this->body['size'] : self::DEFAULT_SIZE;
$from = $this->body['from'] ? $this->body['from'] : 0;
$terms = new TermsAggregation("variantsCompound", $size + $from);
$topHist = new TopHistAggregation(['scope'], 1);
$bucket = new BucketSortAggregation($size, $from);
$terms->subAggregation(new AggregationBuilder('value', $topHist))
->subAggregation(new AggregationBuilder('bucket', $bucket));
if ($factorValues) {
$max = (new MaxAggregation('_script'))->setScript((new MathSumWithFactor($factorValues))->getAlgorithm());
$terms->subAggregation(new AggregationBuilder("factorSort", $max));
}
$params['body']['aggs'] = (new AggregationBuilder("variant", $terms))->toArray();
return $params;
} | @param array $factorValues
@return mixed | entailment |
public function orElse(Maybe $maybe) : Maybe
{
return !isset($this->value) ? $maybe : new static($this->value);
} | {@inheritdoc} | entailment |
public function get($key, $expire = null, $fn = null)
{
$result = $this->master->get($key);
if (false === $result) {
$result = $this->slave->get($key);
}
return $this->processGetResult($key, $result, $expire, $fn);
} | {@inheritdoc} | entailment |
public function remove($key)
{
$result1 = $this->master->remove($key);
$result2 = $this->slave->remove($key);
return $result1 && $result2;
} | {@inheritdoc} | entailment |
public function exists($key)
{
return $this->master->exists($key) || $this->slave->exists($key);
} | {@inheritdoc} | entailment |
public function add($key, $value, $expire = 0)
{
$result = $this->master->add($key, $value, $expire);
// The cache can be added only one time, when added success, set it to the slave cache
if ($result) {
// $result is true, so return the slave cache result only
return $this->slave->set($key, $value, $expire);
}
// false
return $result;
} | {@inheritdoc} | entailment |
public function incr($key, $offset = 1)
{
$result = $this->master->incr($key, $offset);
if (false !== $result && $this->needUpdate($key)) {
return $this->slave->set($key, $result) ? $result : false;
}
return $result;
} | {@inheritdoc} | entailment |
public function clear()
{
$result1 = $this->master->clear();
$result2 = $this->slave->clear();
return $result1 && $result2;
} | {@inheritdoc} | entailment |
public function endTiming($key, $sampleRate = 1)
{
$end = gettimeofday(true);
if (isset($this->timings[$key])) {
$timing = ($end - $this->timings[$key]) * 1000;
$this->timing($key, $timing, $sampleRate);
unset($this->timings[$key]);
return $timing;
}
return null;
} | Ends the timing for a key and sends it to StatsD
@param string $key
@param int|float $sampleRate the rate (0-1) for sampling.
@return float|null | entailment |
public function time($key, \Closure $fn, $sampleRate = 1)
{
$this->startTiming($key);
$return = $fn();
$this->endTiming($key, $sampleRate);
return $return;
} | Executes a Closure and records it's execution time and sends it to StatsD
returns the value the Closure returned
@param string $key
@param \Closure $fn
@param int|float $sampleRate the rate (0-1) for sampling.
@return mixed | entailment |
public function endMemoryProfile($key, $sampleRate = 1)
{
$end = memory_get_usage();
if (array_key_exists($key, $this->memoryProfiles)) {
$memory = ($end - $this->memoryProfiles[$key]);
$this->memory($key, $memory, $sampleRate);
unset($this->memoryProfiles[$key]);
}
} | Ends the memory profiling and sends the value to the server
@param string $key
@param int|float $sampleRate the rate (0-1) for sampling. | entailment |
public function memory($key, $memory = null, $sampleRate = 1)
{
if (null === $memory) {
$memory = memory_get_peak_usage();
}
$this->count($key, $memory, $sampleRate);
} | Report memory usage to StatsD. if memory was not given report peak usage
@param string $key
@param int $memory
@param int|float $sampleRate the rate (0-1) for sampling. | entailment |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.