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
f31eaa9a
Commit
f31eaa9a
authored
Jul 26, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
569348bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
6 deletions
+38
-6
Query.php
lib/Doctrine/Search/Query.php
+38
-6
No files found.
lib/Doctrine/Search/Query.php
View file @
f31eaa9a
...
...
@@ -79,7 +79,7 @@ class Doctrine_Search_Query
return
false
;
break
;
case
1
:
// only one term found, use fast
// only one term found, use fast and simple query
$select
=
'SELECT COUNT(keyword) AS relevance, '
.
$foreignId
;
$from
=
'FROM '
.
$this
->
_table
->
getTableName
();
...
...
@@ -100,17 +100,49 @@ class Doctrine_Search_Query
$where
.=
' AND (position + '
.
$k
.
') = (SELECT position FROM '
.
$this
->
_table
->
getTableName
()
.
' WHERE keyword = ?)'
;
}
}
$groupby
=
'GROUP BY '
.
$foreignId
;
$orderby
=
'ORDER BY relevance'
;
break
;
default
:
$select
=
'SELECT COUNT(keyword) AS relevance, '
.
$foreignId
;
$from
=
'FROM '
.
$this
->
_table
->
getTableName
();
$where
=
'WHERE '
;
$cond
=
array
();
$params
=
array
();
foreach
(
$terms
as
$term
)
{
$data
=
$this
->
parseTerm
(
$term
);
$params
=
array_merge
(
$params
,
$data
[
1
]);
$cond
[]
=
$foreignId
.
' IN (SELECT '
.
$foreignId
.
' FROM '
.
$this
->
_table
->
getTableName
()
.
' '
.
$data
[
0
]
.
')'
;
}
$where
.=
implode
(
' AND '
,
$cond
);
}
$groupby
=
'GROUP BY '
.
$foreignId
;
$orderby
=
'ORDER BY relevance'
;
$this
->
_sql
=
$select
.
' '
.
$from
.
' '
.
$where
.
' '
.
$groupby
.
' '
.
$orderby
;
}
public
function
parseTerm
(
$term
)
{
if
(
strpos
(
$term
,
"'"
)
===
false
)
{
$where
=
'WHERE keyword = ?'
;
$params
=
array
(
$term
);
}
else
{
$term
=
trim
(
$term
,
"' "
);
$where
=
'WHERE keyword = ?'
;
$terms
=
Doctrine_Tokenizer
::
quoteExplode
(
$term
);
$params
=
$terms
;
foreach
(
$terms
as
$k
=>
$word
)
{
if
(
$k
===
0
)
{
continue
;
}
$where
.=
' AND (position + '
.
$k
.
') = (SELECT position FROM '
.
$this
->
_table
->
getTableName
()
.
' WHERE keyword = ?)'
;
}
}
return
array
(
$where
,
$params
);
}
public
function
search2
(
$text
)
{
$text
=
strtolower
(
$text
);
...
...
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