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
c1511dd3
Commit
c1511dd3
authored
Jul 11, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
e6d7127f
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
292 additions
and
187 deletions
+292
-187
Doctrine.php
lib/Doctrine.php
+4
-5
Configurable.php
lib/Doctrine/Configurable.php
+1
-0
Connection.php
lib/Doctrine/Connection.php
+28
-15
Statement.php
lib/Doctrine/Connection/Statement.php
+16
-8
Event.php
lib/Doctrine/Event.php
+1
-0
EventListener.php
lib/Doctrine/EventListener.php
+7
-18
Chain.php
lib/Doctrine/EventListener/Chain.php
+18
-5
Interface.php
lib/Doctrine/EventListener/Interface.php
+5
-2
Manager.php
lib/Doctrine/Manager.php
+1
-0
Record.php
lib/Doctrine/Record.php
+6
-4
Search.php
lib/Doctrine/Search.php
+24
-5
Standard.php
lib/Doctrine/Search/Analyzer/Standard.php
+1
-2
Listener.php
lib/Doctrine/Search/Listener.php
+2
-20
DBTestCase.php
tests/DBTestCase.php
+152
-95
SearchTestCase.php
tests/SearchTestCase.php
+22
-5
run.php
tests/run.php
+4
-3
No files found.
lib/Doctrine.php
View file @
c1511dd3
...
@@ -125,7 +125,7 @@ final class Doctrine
...
@@ -125,7 +125,7 @@ final class Doctrine
*/
*/
const
ATTR_AUTOCOMMIT
=
0
;
const
ATTR_AUTOCOMMIT
=
0
;
const
ATTR_PREFETCH
=
1
;
const
ATTR_PREFETCH
=
1
;
const
ATTR_TIMEOUT
=
2
;
const
ATTR_TIMEOUT
=
2
;
const
ATTR_ERRMODE
=
3
;
const
ATTR_ERRMODE
=
3
;
const
ATTR_SERVER_VERSION
=
4
;
const
ATTR_SERVER_VERSION
=
4
;
const
ATTR_CLIENT_VERSION
=
5
;
const
ATTR_CLIENT_VERSION
=
5
;
...
@@ -142,6 +142,7 @@ final class Doctrine
...
@@ -142,6 +142,7 @@ final class Doctrine
const
ATTR_DRIVER_NAME
=
16
;
const
ATTR_DRIVER_NAME
=
16
;
const
ATTR_STRINGIFY_FETCHES
=
17
;
const
ATTR_STRINGIFY_FETCHES
=
17
;
const
ATTR_MAX_COLUMN_LEN
=
18
;
const
ATTR_MAX_COLUMN_LEN
=
18
;
/**
/**
* Doctrine constants
* Doctrine constants
*/
*/
...
@@ -194,6 +195,8 @@ final class Doctrine
...
@@ -194,6 +195,8 @@ final class Doctrine
const
ATTR_CACHE_LIFESPAN
=
151
;
const
ATTR_CACHE_LIFESPAN
=
151
;
const
ATTR_LOAD_REFERENCES
=
153
;
const
ATTR_LOAD_REFERENCES
=
153
;
const
ATTR_RECORD_LISTENER
=
154
;
const
ATTR_RECORD_LISTENER
=
154
;
const
ATTR_THROW_EXCEPTIONS
=
155
;
/**
/**
* LIMIT CONSTANTS
* LIMIT CONSTANTS
...
@@ -354,10 +357,6 @@ final class Doctrine
...
@@ -354,10 +357,6 @@ final class Doctrine
* constant for composite identifier
* constant for composite identifier
*/
*/
const
IDENTIFIER_COMPOSITE
=
4
;
const
IDENTIFIER_COMPOSITE
=
4
;
const
ACCESSOR_BOTH
=
0
;
const
ACCESSOR_SET
=
1
;
const
ACCESSOR_GET
=
2
;
/**
/**
* constructor
* constructor
*/
*/
...
...
lib/Doctrine/Configurable.php
View file @
c1511dd3
...
@@ -137,6 +137,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
...
@@ -137,6 +137,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
case
Doctrine
::
ATTR_DECIMAL_PLACES
:
case
Doctrine
::
ATTR_DECIMAL_PLACES
:
case
Doctrine
::
ATTR_LOAD_REFERENCES
:
case
Doctrine
::
ATTR_LOAD_REFERENCES
:
case
Doctrine
::
ATTR_RECORD_LISTENER
:
case
Doctrine
::
ATTR_RECORD_LISTENER
:
case
Doctrine
::
ATTR_THROW_EXCEPTIONS
:
break
;
break
;
case
Doctrine
::
ATTR_SEQCOL_NAME
:
case
Doctrine
::
ATTR_SEQCOL_NAME
:
...
...
lib/Doctrine/Connection.php
View file @
c1511dd3
...
@@ -687,19 +687,24 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -687,19 +687,24 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{
{
$this
->
connect
();
$this
->
connect
();
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_PREPARE
,
$statement
);
try
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_PREPARE
,
$statement
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
prePrepare
(
$event
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
prePrepare
(
$event
);
$stmt
=
false
;
if
(
!
$event
->
skipOperation
)
{
$stmt
=
$this
->
dbh
->
prepare
(
$statement
);
}
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
postPrepare
(
$event
);
$stmt
=
false
;
if
(
!
$event
->
skipOperation
)
{
$stmt
=
$this
->
dbh
->
prepare
(
$statement
);
}
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
postPrepare
(
$event
);
return
new
Doctrine_Connection_Statement
(
$this
,
$stmt
);
}
catch
(
Doctrine_Adapter_Exception
$e
)
{
}
catch
(
PDOException
$e
)
{
}
return
new
Doctrine_Connection_Statement
(
$this
,
$stmt
);
$this
->
rethrowException
(
$e
,
$this
);
}
}
/**
/**
* query
* query
...
@@ -791,7 +796,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -791,7 +796,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
catch
(
Doctrine_Adapter_Exception
$e
)
{
}
catch
(
Doctrine_Adapter_Exception
$e
)
{
}
catch
(
PDOException
$e
)
{
}
}
catch
(
PDOException
$e
)
{
}
$this
->
rethrowException
(
$e
);
$this
->
rethrowException
(
$e
,
$this
);
}
}
/**
/**
* exec
* exec
...
@@ -826,15 +831,19 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -826,15 +831,19 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
catch
(
Doctrine_Adapter_Exception
$e
)
{
}
catch
(
Doctrine_Adapter_Exception
$e
)
{
}
catch
(
PDOException
$e
)
{
}
}
catch
(
PDOException
$e
)
{
}
$this
->
rethrowException
(
$e
);
$this
->
rethrowException
(
$e
,
$this
);
}
}
/**
/**
* rethrowException
* rethrowException
*
*
* @throws Doctrine_Connection_Exception
* @throws Doctrine_Connection_Exception
*/
*/
p
rivate
function
rethrowException
(
Exception
$e
)
p
ublic
function
rethrowException
(
Exception
$e
,
$invoker
)
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_ERROR
);
$this
->
getListener
()
->
preError
(
$event
);
$name
=
'Doctrine_Connection_'
.
$this
->
driverName
.
'_Exception'
;
$name
=
'Doctrine_Connection_'
.
$this
->
driverName
.
'_Exception'
;
$exc
=
new
$name
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
());
$exc
=
new
$name
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
());
...
@@ -843,7 +852,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -843,7 +852,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
}
$exc
->
processErrorInfo
(
$e
->
errorInfo
);
$exc
->
processErrorInfo
(
$e
->
errorInfo
);
throw
$exc
;
if
(
$this
->
getAttribute
(
Doctrine
::
ATTR_THROW_EXCEPTIONS
))
{
throw
$exc
;
}
$this
->
getListener
()
->
postError
(
$event
);
}
}
/**
/**
* hasTable
* hasTable
...
...
lib/Doctrine/Connection/Statement.php
View file @
c1511dd3
...
@@ -213,16 +213,24 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -213,16 +213,24 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
*/
*/
public
function
execute
(
$params
=
null
)
public
function
execute
(
$params
=
null
)
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
STMT_EXECUTE
,
$this
->
getQuery
(),
$params
);
try
{
$this
->
_conn
->
getListener
()
->
preExecute
(
$event
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
STMT_EXECUTE
,
$this
->
getQuery
(),
$params
);
$this
->
_conn
->
getListener
()
->
preStmtExecute
(
$event
);
if
(
!
$event
->
skipOperation
)
{
$this
->
_stmt
->
execute
(
$params
);
if
(
!
$event
->
skipOperation
)
{
$this
->
_conn
->
incrementQueryCount
();
$this
->
_stmt
->
execute
(
$params
);
$this
->
_conn
->
incrementQueryCount
();
}
$this
->
_conn
->
getListener
()
->
postStmtExecute
(
$event
);
return
$this
;
}
catch
(
PDOException
$e
)
{
}
catch
(
Doctrine_Adapter_Exception
$e
)
{
}
}
$this
->
_conn
->
getListener
()
->
postExecute
(
$event
);
$this
->
_conn
->
rethrowException
(
$e
,
$this
);
return
$this
;
return
$this
;
}
}
/**
/**
...
...
lib/Doctrine/Event.php
View file @
c1511dd3
...
@@ -39,6 +39,7 @@ class Doctrine_Event
...
@@ -39,6 +39,7 @@ class Doctrine_Event
const
CONN_PREPARE
=
3
;
const
CONN_PREPARE
=
3
;
const
CONN_CONNECT
=
4
;
const
CONN_CONNECT
=
4
;
const
CONN_CLOSE
=
5
;
const
CONN_CLOSE
=
5
;
const
CONN_ERROR
=
6
;
const
STMT_EXECUTE
=
10
;
const
STMT_EXECUTE
=
10
;
const
STMT_FETCH
=
11
;
const
STMT_FETCH
=
11
;
...
...
lib/Doctrine/EventListener.php
View file @
c1511dd3
...
@@ -34,22 +34,6 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
...
@@ -34,22 +34,6 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
*/
*/
class
Doctrine_EventListener
implements
Doctrine_EventListener_Interface
class
Doctrine_EventListener
implements
Doctrine_EventListener_Interface
{
{
public
function
onLoad
(
Doctrine_Record
$record
)
{
}
public
function
onPreLoad
(
Doctrine_Record
$record
)
{
}
public
function
onSleep
(
Doctrine_Record
$record
)
{
}
public
function
onWakeUp
(
Doctrine_Record
$record
)
{
}
public
function
onEvict
(
Doctrine_Record
$record
)
{
}
public
function
onPreEvict
(
Doctrine_Record
$record
)
{
}
public
function
preClose
(
Doctrine_Event
$event
)
public
function
preClose
(
Doctrine_Event
$event
)
{
}
{
}
public
function
postClose
(
Doctrine_Event
$event
)
public
function
postClose
(
Doctrine_Event
$event
)
...
@@ -114,6 +98,11 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
...
@@ -114,6 +98,11 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
public
function
postExec
(
Doctrine_Event
$event
)
public
function
postExec
(
Doctrine_Event
$event
)
{
}
{
}
public
function
preError
(
Doctrine_Event
$event
)
{
}
public
function
postError
(
Doctrine_Event
$event
)
{
}
public
function
preFetch
(
Doctrine_Event
$event
)
public
function
preFetch
(
Doctrine_Event
$event
)
{
}
{
}
public
function
postFetch
(
Doctrine_Event
$event
)
public
function
postFetch
(
Doctrine_Event
$event
)
...
@@ -124,8 +113,8 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
...
@@ -124,8 +113,8 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
public
function
postFetchAll
(
Doctrine_Event
$event
)
public
function
postFetchAll
(
Doctrine_Event
$event
)
{
}
{
}
public
function
preExecute
(
Doctrine_Event
$event
)
public
function
pre
Stmt
Execute
(
Doctrine_Event
$event
)
{
}
{
}
public
function
postExecute
(
Doctrine_Event
$event
)
public
function
post
Stmt
Execute
(
Doctrine_Event
$event
)
{
}
{
}
}
}
lib/Doctrine/EventListener/Chain.php
View file @
c1511dd3
...
@@ -331,7 +331,20 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -331,7 +331,20 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
$listener
->
postExec
(
$event
);
$listener
->
postExec
(
$event
);
}
}
}
}
public
function
preError
(
Doctrine_Event
$event
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
preError
(
$event
);
}
}
public
function
postError
(
Doctrine_Event
$event
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
postError
(
$event
);
}
}
public
function
preFetch
(
Doctrine_Event
$event
)
public
function
preFetch
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
...
@@ -359,17 +372,17 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -359,17 +372,17 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
}
}
}
}
public
function
preExecute
(
Doctrine_Event
$event
)
public
function
pre
Stmt
Execute
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
preExecute
(
$event
);
$listener
->
pre
Stmt
Execute
(
$event
);
}
}
}
}
public
function
postExecute
(
Doctrine_Event
$event
)
public
function
post
Stmt
Execute
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
postExecute
(
$event
);
$listener
->
post
Stmt
Execute
(
$event
);
}
}
}
}
}
}
lib/Doctrine/EventListener/Interface.php
View file @
c1511dd3
...
@@ -55,12 +55,15 @@ interface Doctrine_EventListener_Interface
...
@@ -55,12 +55,15 @@ interface Doctrine_EventListener_Interface
public
function
preExec
(
Doctrine_Event
$event
);
public
function
preExec
(
Doctrine_Event
$event
);
public
function
postExec
(
Doctrine_Event
$event
);
public
function
postExec
(
Doctrine_Event
$event
);
public
function
preError
(
Doctrine_Event
$event
);
public
function
postError
(
Doctrine_Event
$event
);
public
function
preFetch
(
Doctrine_Event
$event
);
public
function
preFetch
(
Doctrine_Event
$event
);
public
function
postFetch
(
Doctrine_Event
$event
);
public
function
postFetch
(
Doctrine_Event
$event
);
public
function
preFetchAll
(
Doctrine_Event
$event
);
public
function
preFetchAll
(
Doctrine_Event
$event
);
public
function
postFetchAll
(
Doctrine_Event
$event
);
public
function
postFetchAll
(
Doctrine_Event
$event
);
public
function
preExecute
(
Doctrine_Event
$event
);
public
function
pre
Stmt
Execute
(
Doctrine_Event
$event
);
public
function
postExecute
(
Doctrine_Event
$event
);
public
function
post
Stmt
Execute
(
Doctrine_Event
$event
);
}
}
lib/Doctrine/Manager.php
View file @
c1511dd3
...
@@ -111,6 +111,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
...
@@ -111,6 +111,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
Doctrine
::
ATTR_LOAD_REFERENCES
=>
true
,
Doctrine
::
ATTR_LOAD_REFERENCES
=>
true
,
Doctrine
::
ATTR_LISTENER
=>
new
Doctrine_EventListener
(),
Doctrine
::
ATTR_LISTENER
=>
new
Doctrine_EventListener
(),
Doctrine
::
ATTR_RECORD_LISTENER
=>
new
Doctrine_Record_Listener
(),
Doctrine
::
ATTR_RECORD_LISTENER
=>
new
Doctrine_Record_Listener
(),
Doctrine
::
ATTR_THROW_EXCEPTIONS
=>
true
,
Doctrine
::
ATTR_LOCKMODE
=>
1
,
Doctrine
::
ATTR_LOCKMODE
=>
1
,
Doctrine
::
ATTR_VLD
=>
false
,
Doctrine
::
ATTR_VLD
=>
false
,
Doctrine
::
ATTR_AUTO_LENGTH_VLD
=>
true
,
Doctrine
::
ATTR_AUTO_LENGTH_VLD
=>
true
,
...
...
lib/Doctrine/Record.php
View file @
c1511dd3
...
@@ -520,6 +520,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -520,6 +520,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
*/
public
function
unserialize
(
$serialized
)
public
function
unserialize
(
$serialized
)
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
RECORD_UNSERIALIZE
);
$this
->
preUnserialize
(
$event
);
$manager
=
Doctrine_Manager
::
getInstance
();
$manager
=
Doctrine_Manager
::
getInstance
();
$connection
=
$manager
->
getConnectionForComponent
(
get_class
(
$this
));
$connection
=
$manager
->
getConnectionForComponent
(
get_class
(
$this
));
...
@@ -540,8 +544,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -540,8 +544,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
(
$this
->
exists
());
$this
->
prepareIdentifiers
(
$this
->
exists
());
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onWakeUp
(
$this
);
$this
->
postUnserialize
(
$event
);
}
}
/**
/**
* getState
* getState
...
@@ -633,8 +637,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -633,8 +637,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
return
$this
;
return
$this
;
}
}
/**
/**
...
...
lib/Doctrine/Search.php
View file @
c1511dd3
...
@@ -54,7 +54,7 @@ class Doctrine_Search
...
@@ -54,7 +54,7 @@ class Doctrine_Search
public
function
analyze
(
$text
)
public
function
analyze
(
$text
)
{
{
return
$this
->
_options
[
'analyzer'
]
->
analyze
(
$text
);
return
$this
->
_options
[
'analyzer'
]
->
analyze
(
$text
);
}
}
public
function
setOption
(
$option
,
$value
)
public
function
setOption
(
$option
,
$value
)
...
@@ -63,6 +63,29 @@ class Doctrine_Search
...
@@ -63,6 +63,29 @@ class Doctrine_Search
return
$this
;
return
$this
;
}
}
public
function
updateIndex
(
Doctrine_Record
$record
)
{
$fields
=
$this
->
getOption
(
'fields'
);
$class
=
$this
->
getOption
(
'className'
);
$name
=
$record
->
getTable
()
->
getComponentName
();
foreach
(
$fields
as
$field
)
{
$data
=
$record
->
get
(
$field
);
$terms
=
$this
->
analyze
(
$data
);
foreach
(
$terms
as
$pos
=>
$term
)
{
$index
=
new
$class
();
$index
->
keyword
=
$term
;
$index
->
position
=
$pos
;
$index
->
field
=
$field
;
$index
->
$name
=
$record
;
$index
->
save
();
}
}
}
public
function
buildDefinition
(
Doctrine_Table
$table
)
public
function
buildDefinition
(
Doctrine_Table
$table
)
{
{
...
@@ -111,9 +134,5 @@ class Doctrine_Search
...
@@ -111,9 +134,5 @@ class Doctrine_Search
if
(
!
$this
->
_options
[
'generateFiles'
])
{
if
(
!
$this
->
_options
[
'generateFiles'
])
{
eval
(
$def
);
eval
(
$def
);
}
}
/**
print "<pre>";
print_r(htmlentities($def));
*/
}
}
}
}
lib/Doctrine/Search/Analyzer/Standard.php
View file @
c1511dd3
...
@@ -283,8 +283,7 @@ class Doctrine_Search_Analyzer_Standard implements Doctrine_Search_Analyzer_Inte
...
@@ -283,8 +283,7 @@ class Doctrine_Search_Analyzer_Standard implements Doctrine_Search_Analyzer_Inte
continue
;
continue
;
}
}
$pos
=
strpos
(
$text
,
$term
);
$ret
[
$i
]
=
$lower
;
$ret
[
$pos
]
=
$lower
;
}
}
}
}
return
$ret
;
return
$ret
;
...
...
lib/Doctrine/Search/Listener.php
View file @
c1511dd3
...
@@ -49,26 +49,8 @@ class Doctrine_Search_Listener extends Doctrine_Record_Listener
...
@@ -49,26 +49,8 @@ class Doctrine_Search_Listener extends Doctrine_Record_Listener
}
}
public
function
postInsert
(
Doctrine_Event
$event
)
public
function
postInsert
(
Doctrine_Event
$event
)
{
{
$fields
=
$this
->
_search
->
getOption
(
'fields'
);
$class
=
$this
->
_search
->
getOption
(
'className'
);
$record
=
$event
->
getInvoker
();
$record
=
$event
->
getInvoker
();
$name
=
$record
->
getTable
()
->
getComponentName
();
$this
->
_search
->
updateIndex
(
$record
);
foreach
(
$fields
as
$field
)
{
$data
=
$record
->
get
(
$field
);
$terms
=
$this
->
_search
->
analyze
(
$data
);
foreach
(
$terms
as
$pos
=>
$term
)
{
$index
=
new
$class
();
$index
->
keyword
=
$term
;
$index
->
position
=
$pos
;
$index
->
field
=
$field
;
$index
->
$name
=
$record
;
$index
->
save
();
}
}
}
}
}
}
tests/DBTestCase.php
View file @
c1511dd3
This diff is collapsed.
Click to expand it.
tests/SearchTestCase.php
View file @
c1511dd3
...
@@ -60,23 +60,39 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
...
@@ -60,23 +60,39 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
$e
->
save
();
$e
->
save
();
}
}
public
function
testQuerying
()
public
function
testQuerying
()
{
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
();
$q
->
select
(
't.title'
)
$q
->
select
(
't.title'
)
->
from
(
'SearchTest t'
)
->
from
(
'SearchTest t'
)
->
innerJoin
(
't.SearchTestIndex i'
)
->
innerJoin
(
't.SearchTestIndex i'
)
->
where
(
'i.keyword = ?'
);
->
where
(
'i.keyword = ?'
);
$array
=
$q
->
execute
(
array
(
'orm'
),
Doctrine_Hydrate
::
HYDRATE_ARRAY
);
$array
=
$q
->
execute
(
array
(
'orm'
),
Doctrine_Hydrate
::
HYDRATE_ARRAY
);
$this
->
assertEqual
(
$array
[
0
][
'title'
],
'Once there was an ORM framework'
);
}
public
function
testUsingWordRange
()
{
$q
=
new
Doctrine_Query
();
$q
->
select
(
't.title, i.*'
)
->
from
(
'SearchTest t'
)
->
innerJoin
(
't.SearchTestIndex i'
)
->
where
(
'i.keyword = ? OR i.keyword = ?'
);
$array
=
$q
->
execute
(
array
(
'orm'
,
'framework'
),
Doctrine_Hydrate
::
HYDRATE_ARRAY
);
$this
->
assertEqual
(
$array
[
0
][
'title'
],
'Once there was an ORM framework'
);
$this
->
assertEqual
(
$array
[
0
][
'title'
],
'Once there was an ORM framework'
);
}
}
public
function
testQueryingReturnsEmptyArrayForStopKeyword
()
public
function
testQueryingReturnsEmptyArrayForStopKeyword
()
{
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
();
$q
->
select
(
't.title'
)
$q
->
select
(
't.title'
)
->
from
(
'SearchTest t'
)
->
from
(
'SearchTest t'
)
->
innerJoin
(
't.SearchTestIndex i'
)
->
innerJoin
(
't.SearchTestIndex i'
)
...
@@ -86,10 +102,11 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
...
@@ -86,10 +102,11 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
count
(
$array
),
0
);
$this
->
assertEqual
(
count
(
$array
),
0
);
}
}
public
function
testQueryingReturnsEmptyArrayForUnknownKeyword
()
public
function
testQueryingReturnsEmptyArrayForUnknownKeyword
()
{
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
();
$q
->
select
(
't.title'
)
$q
->
select
(
't.title'
)
->
from
(
'SearchTest t'
)
->
from
(
'SearchTest t'
)
->
innerJoin
(
't.SearchTestIndex i'
)
->
innerJoin
(
't.SearchTestIndex i'
)
...
@@ -100,7 +117,7 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
...
@@ -100,7 +117,7 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
count
(
$array
),
0
);
$this
->
assertEqual
(
count
(
$array
),
0
);
}
}
}
}
class
SearchTest
extends
Doctrine_Record
class
SearchTest
extends
Doctrine_Record
{
{
public
function
setTableDefinition
()
public
function
setTableDefinition
()
{
{
...
...
tests/run.php
View file @
c1511dd3
...
@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
...
@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
$test->addTestCase(new Doctrine_Ticket330_TestCase());
$test->addTestCase(new Doctrine_Ticket330_TestCase());
*/
*/
/**
*/
/** */
// Connection drivers (not yet fully tested)
// Connection drivers (not yet fully tested)
$test
->
addTestCase
(
new
Doctrine_Connection_Pgsql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Connection_Pgsql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Connection_Oracle_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Connection_Oracle_TestCase
());
...
@@ -315,7 +315,7 @@ $test->addTestCase(new Doctrine_Record_ZeroValues_TestCase());
...
@@ -315,7 +315,7 @@ $test->addTestCase(new Doctrine_Record_ZeroValues_TestCase());
$test
->
addTestCase
(
new
Doctrine_Query_Cache_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Query_Cache_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Cache_Apc_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Cache_Apc_TestCase
());
/**
$test->addTestCase(new Doctrine_Cache_Memcache_TestCase());
$test->addTestCase(new Doctrine_Cache_Memcache_TestCase());
$test->addTestCase(new Doctrine_Cache_Sqlite_TestCase());
$test->addTestCase(new Doctrine_Cache_Sqlite_TestCase());
...
@@ -327,11 +327,12 @@ $test->addTestCase(new Doctrine_Template_TestCase());
...
@@ -327,11 +327,12 @@ $test->addTestCase(new Doctrine_Template_TestCase());
$test->addTestCase(new Doctrine_Import_Builder_TestCase());
$test->addTestCase(new Doctrine_Import_Builder_TestCase());
$test->addTestCase(new Doctrine_Search_TestCase());
$test->addTestCase(new Doctrine_Search_TestCase());
*/
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
$test
->
addTestCase
(
new
Doctrine_NestedSet_SingleRoot_TestCase
());
//
$test->addTestCase(new Doctrine_NestedSet_SingleRoot_TestCase());
// Cache tests
// Cache tests
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
...
...
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