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
32a4639a
Commit
32a4639a
authored
Oct 13, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
batch update functionality added
parent
7d7313ab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
85 deletions
+45
-85
Search.php
lib/Doctrine/Search.php
+45
-25
Template.php
lib/Doctrine/Search/Template.php
+0
-60
No files found.
lib/Doctrine/Search.php
View file @
32a4639a
...
...
@@ -97,35 +97,53 @@ class Doctrine_Search extends Doctrine_Plugin
}
}
public
function
processPending
Table
(
$tableName
,
$indexTableName
,
array
$fields
,
$id
,
$conn
=
null
)
public
function
processPending
(
$limit
=
null
,
$offset
=
null
)
{
if
(
!
(
$conn
instanceof
Doctrine_Connection
))
{
$conn
=
Doctrine_Manager
::
connection
();
}
$fields
=
array_merge
(
$fields
,
array
(
$id
));
$query
=
'SELECT '
.
implode
(
', '
,
$fields
)
.
' FROM '
.
$tableName
.
' WHERE '
.
$id
.
' IN (SELECT foreign_id FROM '
.
$indexTableName
.
') ORDER BY '
.
$id
;
$conn
=
$this
->
_options
[
'ownerTable'
]
->
getConnection
();
$tableName
=
$this
->
_options
[
'ownerTable'
]
->
getTableName
();
$component
=
$this
->
_options
[
'ownerTable'
]
->
getComponentName
();
$id
=
$this
->
_options
[
'ownerTable'
]
->
getIdentifier
();
$class
=
$this
->
getOption
(
'className'
);
$fields
=
$this
->
getOption
(
'fields'
);
$data
=
$conn
->
fetchAll
(
$query
);
try
{
foreach
(
$data
as
$row
)
{
$identifier
=
$row
[
$id
];
$conn
->
beginTransaction
();
unset
(
$row
[
$id
]);
$query
=
'SELECT * FROM '
.
$conn
->
quoteIdentifier
(
$tableName
)
.
' WHERE '
.
$conn
->
quoteIdentifier
(
$id
)
.
' IN (SELECT '
.
$conn
->
quoteIdentifier
(
$id
)
.
' FROM '
.
$conn
->
quoteIdentifier
(
$this
->
_options
[
'pluginTable'
]
->
getTableName
())
.
' WHERE keyword IS NULL)'
;
$rows
=
$conn
->
fetchAll
(
$query
);
foreach
(
$rows
as
$row
)
{
foreach
(
$fields
as
$field
)
{
$data
=
$row
[
$field
];
foreach
(
$row
as
$field
=>
$data
)
{
$terms
=
$this
->
analyze
(
$data
);
foreach
(
$terms
as
$pos
=>
$term
)
{
$conn
->
insert
(
$indexTableName
,
array
(
'keyword'
=>
$field
,
'position'
=>
$pos
,
'field'
=>
$field
,
'foreign_id'
=>
$identifier
));
$index
=
new
$class
();
$index
->
keyword
=
$term
;
$index
->
position
=
$pos
;
$index
->
field
=
$field
;
foreach
((
array
)
$this
->
_options
[
'ownerTable'
]
->
getIdentifier
()
as
$id
)
{
$index
->
$id
=
$row
[
$id
];
}
$index
->
save
();
}
}
}
$conn
->
commit
();
}
catch
(
Doctrine_Exception
$e
)
{
$conn
->
rollback
();
}
}
/**
* insertPending
...
...
@@ -146,6 +164,8 @@ class Doctrine_Search extends Doctrine_Plugin
$className
=
$this
->
getOption
(
'className'
);
$this
->
_options
[
'ownerTable'
]
=
$table
;
if
(
class_exists
(
$className
))
{
return
false
;
}
...
...
lib/Doctrine/Search/Template.php
deleted
100644 → 0
View file @
7d7313ab
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Search_Template
*
* @package Doctrine
* @subpackage Search
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision$
* @link www.phpdoctrine.com
* @since 1.0
*/
class
Doctrine_Search_Template
extends
Doctrine_Template
{
protected
$_search
;
public
function
__construct
(
array
$options
)
{
$this
->
_search
=
new
Doctrine_Search
(
$options
);
}
public
function
setUp
()
{
$this
->
_search
->
buildDefinition
(
$this
->
_table
);
$id
=
$this
->
_table
->
getIdentifier
();
$name
=
$this
->
_table
->
getComponentName
()
.
'Index'
;
$this
->
_search
->
setOption
(
'className'
,
$name
);
foreach
((
array
)
$id
as
$column
)
{
$foreign
[]
=
strtolower
(
$this
->
_table
->
getComponentName
()
.
'_'
.
$column
);
}
$foreign
=
(
count
(
$foreign
)
>
1
)
?
$foreign
:
current
(
$foreign
);
$this
->
hasMany
(
$name
,
array
(
'local'
=>
$id
,
'foreign'
=>
$foreign
));
$this
->
addListener
(
new
Doctrine_Search_Listener
(
$this
->
_search
));
}
}
\ No newline at end of file
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