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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
QueryBuilder.php
extensions/sphinx/QueryBuilder.php
+22
-2
QueryTest.php
tests/unit/extensions/sphinx/QueryTest.php
+4
-0
No files found.
extensions/sphinx/QueryBuilder.php
View file @
0275a224
...
@@ -871,8 +871,28 @@ class QueryBuilder extends Object
...
@@ -871,8 +871,28 @@ class QueryBuilder extends Object
if
(
$value
instanceof
Expression
)
{
if
(
$value
instanceof
Expression
)
{
$actualValue
=
$value
->
expression
;
$actualValue
=
$value
->
expression
;
}
else
{
}
else
{
$actualValue
=
self
::
PARAM_PREFIX
.
count
(
$params
);
if
(
is_array
(
$value
))
{
$params
[
$actualValue
]
=
$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
);
$params
[
$actualValue
]
=
$value
;
}
}
}
$optionLines
[]
=
$name
.
' = '
.
$actualValue
;
$optionLines
[]
=
$name
.
' = '
.
$actualValue
;
}
}
...
...
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