Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
97ca7c9c
Commit
97ca7c9c
authored
Aug 02, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wildcard support for search query language
parent
36fa8016
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
Query.php
lib/Doctrine/Search/Query.php
+28
-9
No files found.
lib/Doctrine/Search/Query.php
View file @
97ca7c9c
...
...
@@ -32,8 +32,6 @@
*/
class
Doctrine_Search_Query
{
const
OPERATOR_OR
=
0
;
const
OPERATOR_AND
=
1
;
/**
* @var Doctrine_Query $query the base query
*/
...
...
@@ -45,6 +43,8 @@ class Doctrine_Search_Query
protected
$_sql
=
''
;
protected
$_params
=
array
();
protected
$_condition
;
/**
...
...
@@ -186,25 +186,44 @@ class Doctrine_Search_Query
$negation
=
false
;
if
(
strpos
(
$term
,
"'"
)
===
false
)
{
$where
=
'keyword = ?'
;
$params
=
array
(
$term
);
$where
=
$this
->
parseWord
(
$term
);
}
else
{
$term
=
trim
(
$term
,
"' "
);
$where
=
'keyword = ?'
;
$terms
=
Doctrine_Tokenizer
::
quoteExplode
(
$term
);
$params
=
$terms
;
$where
=
$this
->
parseWord
(
$terms
[
0
]);
foreach
(
$terms
as
$k
=>
$word
)
{
if
(
$k
===
0
)
{
continue
;
}
$where
.=
' AND (position + '
.
$k
.
') = (SELECT position FROM '
.
$this
->
_table
->
getTableName
()
.
' WHERE
keyword = ?
)'
;
$where
.=
' AND (position + '
.
$k
.
') = (SELECT position FROM '
.
$this
->
_table
->
getTableName
()
.
' WHERE
'
.
$this
->
parseWord
(
$word
)
.
'
)'
;
}
}
return
$where
;
}
public
function
parseWord
(
$word
)
{
if
(
strpos
(
$word
,
'?'
)
!==
false
||
strpos
(
$word
,
'*'
)
!==
false
)
{
$word
=
str_replace
(
'*'
,
'%'
,
$word
);
$where
=
'keyword LIKE ?'
;
$params
=
array
(
$word
);
}
else
{
$where
=
'keyword = ?'
;
}
$this
->
_params
[]
=
$word
;
return
$where
;
}
public
function
getParams
()
{
return
$this
->
_params
;
}
public
function
getSql
()
{
return
$this
->
_sql
;
...
...
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