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
3cea839f
Commit
3cea839f
authored
Oct 14, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
39bfb030
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
36 deletions
+44
-36
Plugin.php
lib/Doctrine/Plugin.php
+2
-5
Search.php
lib/Doctrine/Search.php
+34
-30
Searchable.php
lib/Doctrine/Template/Searchable.php
+8
-1
No files found.
lib/Doctrine/Plugin.php
View file @
3cea839f
...
...
@@ -35,7 +35,8 @@ class Doctrine_Plugin
/**
* @var array $_options an array of plugin specific options
*/
protected
$_options
=
array
(
'generateFiles'
=>
false
);
protected
$_options
=
array
(
'generateFiles'
=>
false
,
'identifier'
=>
false
);
/**
* __get
* an alias for getOption
...
...
@@ -81,10 +82,6 @@ class Doctrine_Plugin
*/
public
function
setOption
(
$name
,
$value
)
{
if
(
!
isset
(
$this
->
_options
[
$name
]))
{
throw
new
Doctrine_Plugin_Exception
(
'Unknown option '
.
$name
);
}
$this
->
_options
[
$name
]
=
$value
;
return
$this
;
...
...
lib/Doctrine/Search.php
View file @
3cea839f
...
...
@@ -34,14 +34,18 @@ class Doctrine_Search extends Doctrine_Plugin
{
const
INDEX_FILES
=
0
;
const
INDEX_TABLE
=
1
;
const
INDEX_TABLE
S
=
1
;
protected
$_options
=
array
(
'generateFiles'
=>
false
,
'type'
=>
self
::
INDEX_TABLES
,
'className'
=>
'%CLASS%Index'
,
'generatePath'
=>
false
,
'resource'
=>
null
,
'batchUpdates'
=>
false
,
'pluginTable'
=>
false
,
'fields'
=>
array
());
'fields'
=>
array
(),
'identifier'
=>
null
,
'connection'
=>
null
);
public
function
__construct
(
array
$options
)
...
...
@@ -51,6 +55,9 @@ class Doctrine_Search extends Doctrine_Plugin
if
(
!
isset
(
$this
->
_options
[
'analyzer'
]))
{
$this
->
_options
[
'analyzer'
]
=
new
Doctrine_Search_Analyzer_Standard
();
}
if
(
!
isset
(
$this
->
_options
[
'connection'
]))
{
$this
->
_options
[
'connection'
]
=
Doctrine_Manager
::
connection
();
}
}
...
...
@@ -104,32 +111,33 @@ class Doctrine_Search extends Doctrine_Plugin
public
function
readTableData
(
$limit
=
null
,
$offset
=
null
)
{
$conn
=
$this
->
_options
[
'resource'
]
->
getConnection
();
$tableName
=
$this
->
_options
[
'resource'
]
->
getTableName
();
$id
=
$this
->
_options
[
'identifier'
];
$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)'
;
$query
=
$conn
->
modifyLimitQuery
(
$query
,
$limit
,
$offset
);
return
$conn
->
fetchAll
(
$query
);
}
public
function
processPending
(
$limit
=
null
,
$offset
=
null
)
{
$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'
);
$id
=
$this
->
_options
[
'identifier'
];
$class
=
$this
->
_options
[
'className'
];
$fields
=
$this
->
_options
[
'fields'
];
$conn
=
$this
->
_options
[
'connection'
];
try
{
$conn
->
beginTransaction
();
$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)'
;
$query
=
$conn
->
modifyLimitQuery
(
$query
,
$limit
,
$offset
);
$rows
=
$conn
->
fetchAll
(
$query
);
$rows
=
$this
->
readTableData
(
$limit
,
$offset
);
foreach
(
$rows
as
$row
)
{
$ids
[]
=
$row
[
$id
];
...
...
@@ -179,14 +187,10 @@ class Doctrine_Search extends Doctrine_Plugin
$conn
->
insert
(
$indexTableName
,
array
(
'foreign_id'
=>
$id
));
}
public
function
buildDefinition
(
Doctrine_Table
$table
)
public
function
buildDefinition
()
{
$name
=
$table
->
getComponentName
();
$className
=
$this
->
getOption
(
'className'
);
$this
->
_options
[
'ownerTable'
]
=
$table
;
if
(
class_exists
(
$className
))
{
return
false
;
}
...
...
@@ -203,18 +207,18 @@ class Doctrine_Search extends Doctrine_Plugin
'primary'
=>
true
,
));
$id
=
$t
able
->
getIdentifier
()
;
$id
=
$t
his
->
_options
[
'identifier'
]
;
$options
=
array
(
'className'
=>
$className
);
$fk
=
$this
->
generateForeignKeys
(
$t
able
);
$fk
=
$this
->
generateForeignKeys
(
$t
his
->
_options
[
'resource'
]
);
$columns
+=
$fk
;
$relations
=
$this
->
generateRelation
(
$t
able
,
$fk
);
$relations
=
$this
->
generateRelation
(
$t
his
->
_options
[
'resource'
]
,
$fk
);
$this
->
generateClass
(
$options
,
$columns
,
$relations
);
$this
->
_options
[
'pluginTable'
]
=
$t
able
->
getConnection
()
->
getTable
(
$this
->
_options
[
'className'
]);
$this
->
_options
[
'pluginTable'
]
=
$t
his
->
_options
[
'connection'
]
->
getTable
(
$this
->
_options
[
'className'
]);
return
true
;
}
...
...
lib/Doctrine/Template/Searchable.php
View file @
3cea839f
...
...
@@ -52,10 +52,17 @@ class Doctrine_Template_Searchable extends Doctrine_Template
$this
->
_plugin
->
setOption
(
'className'
,
str_replace
(
'%CLASS%'
,
$name
,
$className
));
$className
=
$this
->
_plugin
->
getOption
(
'className'
);
}
$this
->
_plugin
->
buildDefinition
(
$this
->
_table
);
$this
->
_plugin
->
setOption
(
'resource'
,
$this
->
_table
);
$this
->
_plugin
->
setOption
(
'identifier'
,
$this
->
_table
->
getIdentifier
());
$this
->
_plugin
->
buildDefinition
();
$this
->
hasMany
(
$className
,
array
(
'local'
=>
$id
,
'foreign'
=>
$id
));
$this
->
addListener
(
new
Doctrine_Search_Listener
(
$this
->
_plugin
));
}
public
function
processPending
(
$limit
=
null
,
$offset
=
null
)
{
$this
->
_plugin
->
processPending
(
$limit
,
$offset
);
}
}
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