From 2555734b8905246f2da5cd12962771c2f6aa2efe Mon Sep 17 00:00:00 2001 From: Alpha Date: Tue, 30 Sep 2014 20:10:11 -0400 Subject: [PATCH 1/3] add access to SphinxQL\Helper class --- src/mnshankar/Sphinxql/Sphinxql.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mnshankar/Sphinxql/Sphinxql.php b/src/mnshankar/Sphinxql/Sphinxql.php index bb855d2..3d339c5 100644 --- a/src/mnshankar/Sphinxql/Sphinxql.php +++ b/src/mnshankar/Sphinxql/Sphinxql.php @@ -16,6 +16,14 @@ public function query() { return $this->library->forge($this->library->getConnection()); } + /** + * return the library SphinxQL helper object + * @return \Foolz\SphinxQL\Helper + */ + public function helper() + { + return \Foolz\SphinxQL\Helper::create($this->library->getConnection()); + } /** * set the hits array * @param array $hits - the array returned by executing the SphinxQL @@ -59,4 +67,4 @@ public function raw( $query ) { return $this->library->getConnection()->query($query); } -} \ No newline at end of file +} From f87e9eae47a8b59faa40e5f263027009dffe80dc Mon Sep 17 00:00:00 2001 From: Alpha Date: Tue, 30 Sep 2014 20:14:59 -0400 Subject: [PATCH 2/3] add escape and escape bypass API --- src/mnshankar/Sphinxql/Sphinxql.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/mnshankar/Sphinxql/Sphinxql.php b/src/mnshankar/Sphinxql/Sphinxql.php index 3d339c5..b979905 100644 --- a/src/mnshankar/Sphinxql/Sphinxql.php +++ b/src/mnshankar/Sphinxql/Sphinxql.php @@ -67,4 +67,22 @@ public function raw( $query ) { return $this->library->getConnection()->query($query); } + /** + * avoids having the expressions escaped + * @param string $string the string to keep unaltered + * @return \Foolz\SphinxQL\Expression the new Expression + */ + public static function expr($string) + { + return \Foolz\SphinxQL\SphinxQL::expr($string); + } + /** + * escapes the input with \MySQLi::real_escape_string + * @param string $value the string to escape + * @return string the escaped string + */ + public function escape($value) + { + return $this->library->getConnection()->escape($value); + } } From 4fd2764000d7c10d818af080cc4d4ccc0dc2f11c Mon Sep 17 00:00:00 2001 From: Alpha Date: Tue, 30 Sep 2014 20:19:15 -0400 Subject: [PATCH 3/3] normalize whitespace (no functional change) --- src/mnshankar/Sphinxql/Sphinxql.php | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mnshankar/Sphinxql/Sphinxql.php b/src/mnshankar/Sphinxql/Sphinxql.php index b979905..7b16cfc 100644 --- a/src/mnshankar/Sphinxql/Sphinxql.php +++ b/src/mnshankar/Sphinxql/Sphinxql.php @@ -2,11 +2,11 @@ namespace mnshankar\Sphinxql; class Sphinxql { - protected $library; + protected $library; protected $hits; public function __construct(\Foolz\SphinxQL\SphinxQL $library) { - $this->library = $library; + $this->library = $library; } /** * return the library SphinxQL object for chaining other calls @@ -14,7 +14,7 @@ public function __construct(\Foolz\SphinxQL\SphinxQL $library) */ public function query() { - return $this->library->forge($this->library->getConnection()); + return $this->library->forge($this->library->getConnection()); } /** * return the library SphinxQL helper object @@ -26,7 +26,7 @@ public function helper() } /** * set the hits array - * @param array $hits - the array returned by executing the SphinxQL + * @param array $hits - the array returned by executing the SphinxQL * @return \mnshankar\Sphinxql\Sphinxql */ public function with($hits) @@ -35,7 +35,7 @@ public function with($hits) return $this; } /** - * if name is null, return id's + * if name is null, return id's * if name is class (model) return model->get() * if name is table return table->get() * @param string $name @@ -43,29 +43,29 @@ public function with($hits) * @return mixed (either array or eloquentcollection) */ public function get($name=null, $key='id') - { - $matchids = array_pluck($this->hits, $key); + { + $matchids = array_pluck($this->hits, $key); if ($name===null) { return $matchids; - } + } if (class_exists($name)) - { - $result = call_user_func_array($name . "::whereIn", array($key, $matchids))->get(); + { + $result = call_user_func_array($name . "::whereIn", array($key, $matchids))->get(); } - else + else { $result = \DB::table($name)->whereIn($key, $matchids)->get(); - } + } return $result; - } + } /** - * Execute raw query against the sphinx server + * Execute raw query against the sphinx server * @param string $query */ public function raw( $query ) { - return $this->library->getConnection()->query($query); + return $this->library->getConnection()->query($query); } /** * avoids having the expressions escaped