function __construct(Database $db, $into) { parent::__construct($db); $this->_table = str_replace($this->getGraveAccent(), '', $into); // TODO null check on $into return $this; }
/** * 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); }
/** * {@inheritdoc} */ public function toArray() { $array = parent::toArray(); if (isset($array['script'])) { $array['script'] = $array['script']['script']; } return $array; }
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; }
/** * {@inheritdoc} */ public function toArray() { $array = parent::toArray(); $baseName = $this->_getBaseName(); if (isset($array[$baseName]['query'])) { $array[$baseName]['query'] = $array[$baseName]['query']['query']; } return $array; }
/** * @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); } }
/** * * 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; }
/** * @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(); }
/** * @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(); }
/** * @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(); }
/** * @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']; }
/** * 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]; } }
/** * 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); } }
/** * 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()); }
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; }
function __construct(Database $db, $table) { parent::__construct($db); $this->_table = $table; return $this; }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdContent' => 'id_content', 'Pseudo' => 'pseudo', 'IdUser' => 'id_user', 'IdGroupe' => 'id_groupe', 'Langue' => 'langue', 'Titre' => 'titre', 'Description' => 'description', 'ArticleTinymce' => 'article_tinymce', 'Uri' => 'uri', 'UriModule' => 'uri_module', 'MetaTitre' => 'meta_titre', 'MetaDescription' => 'meta_description', 'MetaKeys' => 'meta_keys', 'DateCreation' => 'date_creation')); }
/** * @param string $field * * @return SolrQuery */ public function addField($field) { $entityFieldNames = array_flip($this->mappedFields); if (array_key_exists($field, $entityFieldNames)) { parent::addField($entityFieldNames[$field]); } return $this; }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdUser' => 'id_user', 'IdGroupe' => 'id_groupe', 'Uri' => 'uri', 'Active' => 'active', 'Comments' => 'comments', 'Partage' => 'partage', 'Facebook' => 'facebook', 'IdFacebook' => 'id_facebook', 'Disqus' => 'disqus', 'IdDisqus' => 'id_disqus', 'Mailsender' => 'mailsender', 'Sendto' => 'sendto', 'InRss' => 'in_rss', 'Ordre' => 'ordre', 'GroupeTraduction' => 'groupe_traduction', 'DateCreation' => 'date_creation', 'IdModo' => 'id_modo', 'ValModo' => 'val_modo', 'DateModo' => 'date_modo')); }
/** * @return array */ public function toArray() { if (sizeof($this->_functions)) { $this->setParam('functions', $this->_functions); } return parent::toArray(); }
/** * Sets nested query. * * @param \Elastica\Query\AbstractQuery $query * * @return $this */ public function setQuery(AbstractQuery $query) { return $this->setParam('query', $query->toArray()); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdParent' => 'id_parent', 'UriModule' => 'uri_module', 'GroupeTraduction' => 'groupe_traduction', 'Ordre' => 'ordre', 'DateCreation' => 'date_creation')); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdSession' => 'id_session', 'IdUser' => 'id_user', 'IdGroupe' => 'id_groupe', 'Langue' => 'langue', 'Title' => 'title', 'UriModule' => 'uri_module', 'IdContent' => 'id_content', 'Action' => 'action', 'IpUser' => 'ip_user', 'UrlPage' => 'url_page', 'UrlReferer' => 'url_referer', 'Date' => 'date')); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdModule' => 'id_module', 'Langue' => 'langue', 'Nom' => 'nom', 'Titre' => 'titre', 'Description' => 'description', 'SendMailTo' => 'send_mail_to', 'TopTinymce' => 'top_tinymce', 'BottomTinymce' => 'bottom_tinymce', 'Extras' => 'extras', 'SendMailUser' => 'send_mail_user', 'SendMailName' => 'send_mail_name', 'SendMailEmail' => 'send_mail_email', 'SendMailSujet' => 'send_mail_sujet', 'SendMailMessage' => 'send_mail_message', 'MetaTitre' => 'meta_titre', 'MetaDescription' => 'meta_description', 'MetaKeys' => 'meta_keys', 'MetaFacebookType' => 'meta_facebook_type', 'MetaFacebookTitre' => 'meta_facebook_titre', 'MetaFacebookDescription' => 'meta_facebook_description', 'MetaFacebookImage' => 'meta_facebook_image', 'MetaTwitterType' => 'meta_twitter_type', 'MetaTwitterTitre' => 'meta_twitter_titre', 'MetaTwitterDescription' => 'meta_twitter_description', 'MetaTwitterImage' => 'meta_twitter_image', 'MetaTwitterPlayer' => 'meta_twitter_player', 'DateModification' => 'date_modification')); }
/** * Converts query to array * * @return array Query array * @see \Elastica\Query\AbstractQuery::toArray() */ public function toArray() { $this->setParam($this->_field, array('query' => $this->_queryString)); return parent::toArray(); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'Uri' => 'uri', 'CanDelete' => 'can_delete', 'GroupeTraduction' => 'groupe_traduction', 'DateCreation' => 'date_creation')); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'UriModule' => 'uri_module', 'Sujet' => 'sujet', 'Nom' => 'nom', 'Email' => 'email', 'Message' => 'message', 'Téléphone' => 'telephone', 'Lu' => 'lu', 'Archive' => 'archive', 'DateCreation' => 'date_creation', 'DateArchive' => 'date_archive', 'DateLu' => 'date_lu')); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdUser' => 'id_user', 'IdFacebook' => 'id_facebook', 'Name' => 'name', 'Email' => 'email', 'FirstName' => 'first_name', 'MiddleName' => 'middle_name', 'LastName' => 'last_name', 'Gender' => 'gender', 'Link' => 'link', 'Birthday' => 'birthday', 'Location' => 'location', 'Timezone' => 'timezone', 'AccessToken' => 'access_token', 'DateCreation' => 'date_creation', 'DateModification' => 'date_modification')); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdUser' => 'id_user', 'IdGroupe' => 'id_groupe', 'Nom' => 'nom', 'Email' => 'email', 'Description' => 'description', 'Newsletter' => 'newsletter', 'ClientIp' => 'client_ip', 'DateCreation' => 'date_creation')); }
public function _getMap() { $parentMap = parent::_getMap(); return array_merge($parentMap, array('Id' => 'id', 'IdOrder' => 'id_order', 'TypeOrder' => 'type_order', 'UriModule' => 'uri_module', 'IdContent' => 'id_content', 'RealAmount' => 'real_amount', 'Title' => 'title', 'TotalAmount' => 'total_amount', 'Quantity' => 'quantity', 'Discount' => 'discount', 'DateCreation' => 'date_creation', 'DateModification' => 'date_modification')); }