Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
0275a224
Commit
0275a224
authored
Nov 13, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Option array value support added to "yii\sphinx\Query"
parent
aae221dd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
QueryBuilder.php
extensions/sphinx/QueryBuilder.php
+20
-0
QueryTest.php
tests/unit/extensions/sphinx/QueryTest.php
+4
-0
No files found.
extensions/sphinx/QueryBuilder.php
View file @
0275a224
...
@@ -871,9 +871,29 @@ class QueryBuilder extends Object
...
@@ -871,9 +871,29 @@ class QueryBuilder extends Object
if
(
$value
instanceof
Expression
)
{
if
(
$value
instanceof
Expression
)
{
$actualValue
=
$value
->
expression
;
$actualValue
=
$value
->
expression
;
}
else
{
}
else
{
if
(
is_array
(
$value
))
{
$actualValueParts
=
[];
foreach
(
$value
as
$key
=>
$valuePart
)
{
if
(
is_numeric
(
$key
))
{
$actualValuePart
=
''
;
}
else
{
$actualValuePart
=
$key
.
' = '
;
}
if
(
$valuePart
instanceof
Expression
)
{
$actualValuePart
.=
$valuePart
->
expression
;
}
else
{
$phName
=
self
::
PARAM_PREFIX
.
count
(
$params
);
$params
[
$phName
]
=
$valuePart
;
$actualValuePart
.=
$phName
;
}
$actualValueParts
[]
=
$actualValuePart
;
}
$actualValue
=
'('
.
implode
(
', '
,
$actualValueParts
)
.
')'
;
}
else
{
$actualValue
=
self
::
PARAM_PREFIX
.
count
(
$params
);
$actualValue
=
self
::
PARAM_PREFIX
.
count
(
$params
);
$params
[
$actualValue
]
=
$value
;
$params
[
$actualValue
]
=
$value
;
}
}
}
$optionLines
[]
=
$name
.
' = '
.
$actualValue
;
$optionLines
[]
=
$name
.
' = '
.
$actualValue
;
}
}
return
'OPTION '
.
implode
(
', '
,
$optionLines
);
return
'OPTION '
.
implode
(
', '
,
$optionLines
);
...
...
tests/unit/extensions/sphinx/QueryTest.php
View file @
0275a224
...
@@ -131,6 +131,10 @@ class QueryTest extends SphinxTestCase
...
@@ -131,6 +131,10 @@ class QueryTest extends SphinxTestCase
->
where
(
"MATCH('about')"
)
->
where
(
"MATCH('about')"
)
->
options
([
->
options
([
'cutoff'
=>
50
,
'cutoff'
=>
50
,
'field_weights'
=>
[
'title'
=>
10
,
'content'
=>
3
,
],
])
])
->
all
(
$connection
);
->
all
(
$connection
);
$this
->
assertNotEmpty
(
$rows
);
$this
->
assertNotEmpty
(
$rows
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment