本文整理汇总了PHP中AbstractQuery类的典型用法代码示例。如果您正苦于以下问题:PHP AbstractQuery类的具体用法?PHP AbstractQuery怎么用?PHP AbstractQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createInstanceByQueryString
/**
* Creates an instance of Query based on given query string.
*
* @param string $query SPARQL query string to use for class instantiation.
* @return Query Instance of Query.
*/
public function createInstanceByQueryString($query)
{
switch (AbstractQuery::getQueryType($query)) {
case 'askQuery':
return new AskQueryImpl($query);
case 'describeQuery':
return new DescribeQueryImpl($query);
case 'graphQuery':
return new GraphQueryImpl($query);
case 'selectQuery':
return new SelectQueryImpl($query);
case 'updateQuery':
return new UpdateQueryImpl($query);
default:
throw new \Exception('Unknown query type: ' . $query);
}
}
示例2: setNegativeQuery
/**
* Set the negative query for this Boosting Query
* @param AbstractQuery $query
* @return \Elastica\Query\Boosting
*/
public function setNegativeQuery(AbstractQuery $query)
{
return $this->setParam('negative', $query->toArray());
}
示例3:
function __construct(Database $db, $into)
{
parent::__construct($db);
$this->_table = str_replace($this->getGraveAccent(), '', $into);
// TODO null check on $into
return $this;
}
示例4: tableRaw
/**
* Specify the tabe to insert in to
*
* @param string $table
* @param array $params
* @return $this
* @throws \RuntimeException
*/
public function tableRaw($table, array $params = array())
{
if (count($this->tables) != 0) {
throw new \RuntimeException("You may not set multiple tables");
}
return parent::tableRaw($table, $params);
}
示例5: toArray
/**
* {@inheritdoc}
*/
public function toArray()
{
$array = parent::toArray();
if (isset($array['script'])) {
$array['script'] = $array['script']['script'];
}
return $array;
}
示例6: foreach
function __construct(Database $db, array $fields = null)
{
parent::__construct($db);
foreach ($fields as $field) {
$this->_fields[] = str_replace($this->getGraveAccent(), '', $field);
// add the field to the array of fields, remove any `s for the field name
}
return $this;
}
示例7: toArray
/**
* {@inheritdoc}
*/
public function toArray()
{
$array = parent::toArray();
$baseName = $this->_getBaseName();
if (isset($array[$baseName]['query'])) {
$array[$baseName]['query'] = $array[$baseName]['query']['query'];
}
return $array;
}
示例8: __construct
/**
* @param string|Table|null $table
* @param string|array|Column[] $cols
*/
public function __construct($table = null, $cols = array(Column::ALL))
{
parent::__construct();
if ($table) {
$this->setTable($table);
}
if (count($cols)) {
$this->setColumns($cols);
}
}
示例9: getBindValues
/**
*
* Gets the values to bind to placeholders, including any 'where' values
* (needed for INSERT and UPDATE).
*
* @return array
*
*/
public function getBindValues()
{
$bind_values = parent::getBindValues();
$i = 1;
foreach ($this->bind_where as $val) {
$bind_values[$i] = $val;
$i++;
}
return $bind_values;
}
示例10: getQuery
/**
* @return string
*
* @throws \RuntimeException if documentName is null
*/
public function getQuery()
{
$documentName = $this->documentName;
if ($documentName == null) {
throw new \RuntimeException('documentName should not be null');
}
$query = sprintf('id:%s_*', $documentName);
$this->setQuery($query);
return parent::getQuery();
}
示例11: getQuery
/**
* @return string
*
* @throws \RuntimeException if documentName is null
*/
public function getQuery()
{
$documentNameField = $this->document->document_name_s;
if ($documentNameField == null) {
throw new \RuntimeException('documentName should not be null');
}
$query = sprintf('document_name_s:%s', $documentNameField);
$this->setQuery($query);
return parent::getQuery();
}
示例12: getQuery
/**
* @return string
*
* @throws \RuntimeException when id or document_name is null
*/
public function getQuery()
{
$idField = $this->documentKey;
if ($idField == null) {
throw new \RuntimeException('id should not be null');
}
$query = sprintf('id:%s', $idField);
$this->setQuery($query);
return parent::getQuery();
}
示例13: toArray
/**
* @return array
*/
public function toArray()
{
$array = parent::toArray();
// if there are no params, it's ok, but ES will throw exception if json
// will be like {"top_hits":[]} instead of {"top_hits":{}}
if (empty($array['inner_hits'])) {
$array['inner_hits'] = new \stdClass();
}
return $array['inner_hits'];
}
示例14: __construct
/**
* Constructor.
*
* @param string optional $query SPARQL query string to initialize this instance.
*/
public function __construct($query = '')
{
parent::__construct($query);
if (null === $this->query) {
return;
}
$parts = array('select' => array(), 'from' => array(), 'from_named' => array(), 'where' => array(), 'order' => array(), 'limit' => array(), 'offset' => array());
// regex for variables
$var = '[?$]{1}[\\w\\d]+';
$tokens = array('select' => '/(' . '((SELECT(\\s)+)(DISTINCT(\\s)+)' . '?(COUNT(\\s)*(\\(.*?\\)(\\s)))?)(\\?\\w+\\s+|\\*)*' . '(\\(LANG\\(\\?[a-zA-Z0-9\\_]+\\)\\)* as{1}\\s\\?[a-zA-Z0-9\\_]+)*' . ')/si', 'from' => '/FROM\\s+<(.+?)>/i', 'from_named' => '/FROM\\s+NAMED\\s+<(.+?)>/i', 'where' => '/(WHERE\\s+)?\\{.*\\}/si', 'order' => '/ORDER\\s+BY((\\s+' . $var . '|\\s+(ASC|DESC)\\s*\\(\\s*' . $var . '\\s*\\))+)/i', 'limit' => '/LIMIT\\s+(\\d+)/i', 'offset' => '/OFFSET\\s+(\\d+)/i');
foreach ($tokens as $key => $pattern) {
preg_match_all($pattern, $query, $parts[$key]);
}
if (isset($parts['select'][0][0])) {
$this->queryParts['select'] = trim($parts['select'][0][0]);
}
/**
* FROM
*/
if (isset($parts['from'][1][0])) {
$this->queryParts['graphs'] = $parts['from'][1];
}
/**
* FROM NAMED
*/
if (isset($parts['from_named'][1][0])) {
$this->queryParts['named_graphs'] = $parts['from_named'][1];
}
/**
* WHERE
*/
if (isset($parts['where'][0][0])) {
$this->queryParts['where'] = $parts['where'][0][0];
}
/**
* ORDER BY
*/
if (isset($parts['order'][1][0])) {
$this->queryParts['order'] = trim($parts['order'][1][0]);
}
/**
* LIMIT
*/
if (isset($parts['limit'][1][0])) {
$this->queryParts['limit'] = $parts['limit'][1][0];
}
/**
* OFFSET
*/
if (isset($parts['offset'][1][0])) {
$this->queryParts['offset'] = $parts['offset'][1][0];
}
}
示例15: toArray
public function toArray()
{
$array = parent::toArray();
// If _id is provided, perform MLT on an existing document from the index
// If _source is provided, perform MLT on a document provided as an input
if (!empty($array['more_like_this']['like']['_id'])) {
$doc = $array['more_like_this']['like'];
$doc = array_intersect_key($doc, array('_index' => 1, '_type' => 1, '_id' => 1));
$array['more_like_this']['like'] = $doc;
} elseif (!empty($array['more_like_this']['like']['_source'])) {
$doc = $array['more_like_this']['like'];
$doc['doc'] = $array['more_like_this']['like']['_source'];
unset($doc['_id']);
unset($doc['_source']);
$array['more_like_this']['like'] = $doc;
}
return $array;
}