Skip to content

Commit 3de4ef3

Browse files
committed
Merge pull request #67 from alpha0010/master
Remove unusable functions
2 parents 107c337 + dcb697f commit 3de4ef3

File tree

4 files changed

+21
-97
lines changed

4 files changed

+21
-97
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,6 @@ $result = SphinxQL::create($this->conn)
386386
* `Helper::create($conn)->showStatus() => 'SHOW STATUS'`
387387
* `Helper::create($conn)->shotTables() => 'SHOW TABLES'`
388388
* `Helper::create($conn)->showVariables() => 'SHOW VARIABLES'`
389-
* `Helper::create($conn)->showSessionVariables() => 'SHOW SESSION VARIABLES'`
390-
* `Helper::create($conn)->showGlobalVariables() => 'SHOW GLOBAL VARIABLES'`
391389
* `Helper::create($conn)->setVariable($name, $value, $global = false)`
392390
* `Helper::create($conn)->callSnippets($data, $index, $query, $options = array())`
393391
* `Helper::create($conn)->callKeywords($text, $index, $hits = null)`

src/Helper.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,6 @@ public function showVariables()
130130
return $this->query('SHOW VARIABLES');
131131
}
132132

133-
/**
134-
* Runs query: SHOW SESSION VARIABLES
135-
*
136-
* @return SphinxQL A SphinxQL object ready to be ->execute();
137-
*/
138-
public function showSessionVariables()
139-
{
140-
return $this->query('SHOW SESSION VARIABLES');
141-
}
142-
143-
/**
144-
* Runs query: SHOW GLOBAL VARIABLES
145-
*
146-
* @return SphinxQL
147-
*/
148-
public function showGlobalVariables()
149-
{
150-
return $this->query('SHOW GLOBAL VARIABLES');
151-
}
152-
153133
/**
154134
* SET syntax
155135
*

src/SphinxQL.php

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -483,28 +483,10 @@ public function compileWhere()
483483
}
484484

485485
if (!empty($this->where)) {
486-
$just_opened = false;
487-
488486
foreach ($this->where as $key => $where) {
489-
if (in_array($where['ext_operator'], array('AND (', 'OR (', ')'))) {
490-
// if match is not empty we've got to use an operator
491-
if ($key == 0 || ! empty($this->match)) {
492-
$query .= '(';
493-
494-
$just_opened = true;
495-
} else {
496-
$query .= $where['ext_operator'].' ';
497-
}
498-
499-
continue;
487+
if ($key > 0 || !empty($this->match)) {
488+
$query .= 'AND ';
500489
}
501-
502-
if ($key > 0 && !$just_opened || !empty($this->match)) {
503-
$query .= $where['ext_operator'].' '; // AND/OR
504-
}
505-
506-
$just_opened = false;
507-
508490
$query .= $this->compileFilterCondition($where);
509491
}
510492
}
@@ -949,19 +931,17 @@ public function match($column, $value = null, $half = false)
949931
* @param string $column The column name
950932
* @param string $operator The operator to use
951933
* @param string $value The value to check against
952-
* @param boolean $or If it should be prepended with OR (true) or AND (false) - not available as for Sphinx 2.0.2
953934
*
954935
* @return SphinxQL
955936
*/
956-
public function where($column, $operator, $value = null, $or = false)
937+
public function where($column, $operator, $value = null)
957938
{
958939
if ($value === null) {
959940
$value = $operator;
960941
$operator = '=';
961942
}
962943

963944
$this->where[] = array(
964-
'ext_operator' => $or ? 'OR' : 'AND',
965945
'column' => $column,
966946
'operator' => $operator,
967947
'value' => $value
@@ -970,58 +950,6 @@ public function where($column, $operator, $value = null, $or = false)
970950
return $this;
971951
}
972952

973-
/**
974-
* OR WHERE - at this time (Sphinx 2.0.2) it's not available
975-
*
976-
* @param string $column The column name
977-
* @param string $operator The operator to use
978-
* @param mixed $value The value to compare against
979-
*
980-
* @return SphinxQL
981-
*/
982-
public function orWhere($column, $operator, $value = null)
983-
{
984-
$this->where($column, $operator, $value, true);
985-
986-
return $this;
987-
}
988-
989-
/**
990-
* Opens a parenthesis prepended with AND (where necessary)
991-
*
992-
* @return SphinxQL
993-
*/
994-
public function whereOpen()
995-
{
996-
$this->where[] = array('ext_operator' => 'AND (');
997-
998-
return $this;
999-
}
1000-
1001-
/**
1002-
* Opens a parenthesis prepended with OR (where necessary)
1003-
*
1004-
* @return SphinxQL
1005-
*/
1006-
public function orWhereOpen()
1007-
{
1008-
$this->where[] = array('ext_operator' => 'OR (');
1009-
1010-
return $this;
1011-
}
1012-
1013-
/**
1014-
* Closes a parenthesis in WHERE
1015-
*
1016-
* @return SphinxQL
1017-
*/
1018-
public function whereClose()
1019-
{
1020-
$this->where[] = array('ext_operator' => ')');
1021-
1022-
return $this;
1023-
}
1024-
1025953
/**
1026954
* GROUP BY clause
1027955
* Adds to the previously added columns

tests/SphinxQL/SphinxQLTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,24 @@ public function testWhere()
375375
->getStored();
376376

377377
$this->assertCount(6, $result);
378+
379+
$result = SphinxQL::create(self::$conn)->select()
380+
->from('rt')
381+
->where('gid', '>', 300)
382+
->where('id', '!=', 15)
383+
->execute()
384+
->getStored();
385+
386+
$this->assertCount(5, $result);
387+
388+
$result = SphinxQL::create(self::$conn)->select()
389+
->from('rt')
390+
->match('content', 'content')
391+
->where('gid', '>', 200)
392+
->execute()
393+
->getStored();
394+
395+
$this->assertCount(1, $result);
378396
}
379397

380398
/**

0 commit comments

Comments
 (0)