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
3cd4fc55
Commit
3cd4fc55
authored
Aug 02, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Intermediate checkin.
parent
e704cd0f
Changes
22
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
790 additions
and
880 deletions
+790
-880
ActiveEntity.php
lib/Doctrine/ActiveEntity.php
+455
-0
Configuration.php
lib/Doctrine/Configuration.php
+2
-2
Connection.php
lib/Doctrine/Connection.php
+34
-95
Mock.php
lib/Doctrine/Connection/Mock.php
+4
-1
Statement.php
lib/Doctrine/Connection/Statement.php
+29
-53
DatabasePlatform.php
lib/Doctrine/DatabasePlatform.php
+87
-48
FirebirdPlatform.php
lib/Doctrine/DatabasePlatform/FirebirdPlatform.php
+0
-20
MsSqlPlatform.php
lib/Doctrine/DatabasePlatform/MsSqlPlatform.php
+0
-18
MySqlPlatform.php
lib/Doctrine/DatabasePlatform/MySqlPlatform.php
+40
-42
OraclePlatform.php
lib/Doctrine/DatabasePlatform/OraclePlatform.php
+3
-20
PostgreSqlPlatform.php
lib/Doctrine/DatabasePlatform/PostgreSqlPlatform.php
+36
-26
SqlitePlatform.php
lib/Doctrine/DatabasePlatform/SqlitePlatform.php
+0
-20
Entity.php
lib/Doctrine/Entity.php
+28
-479
RecordDriver.php
lib/Doctrine/Hydrator/RecordDriver.php
+8
-8
Parser.php
lib/Doctrine/Query/Parser.php
+0
-1
Atom.php
lib/Doctrine/Query/Production/Atom.php
+17
-16
Scanner.php
lib/Doctrine/Query/Scanner.php
+30
-15
Parser.php
lib/Doctrine/Relation/Parser.php
+2
-1
Mysql.php
lib/Doctrine/Sequence/Mysql.php
+4
-4
Oracle.php
lib/Doctrine/Sequence/Oracle.php
+4
-4
AccessorTest.php
tests/Orm/Entity/AccessorTest.php
+4
-6
SelectSqlGenerationTest.php
tests/Orm/Query/SelectSqlGenerationTest.php
+3
-1
No files found.
lib/Doctrine/ActiveEntity.php
0 → 100644
View file @
3cd4fc55
This diff is collapsed.
Click to expand it.
lib/Doctrine/Configuration.php
View file @
3cd4fc55
...
@@ -63,13 +63,13 @@ class Doctrine_Configuration
...
@@ -63,13 +63,13 @@ class Doctrine_Configuration
/**
/**
* Initializes the attributes.
* Initializes the attributes.
* Changes null default values to references to the Null object to allow
* fast isset() checks instead of array_key_exists().
*
*
* @return void
* @return void
*/
*/
private
function
_initAttributes
()
private
function
_initAttributes
()
{
{
// Change null default values to references to the Null object to allow
// fast isset() checks instead of array_key_exists().
foreach
(
$this
->
_attributes
as
$key
=>
$value
)
{
foreach
(
$this
->
_attributes
as
$key
=>
$value
)
{
if
(
$value
===
null
)
{
if
(
$value
===
null
)
{
$this
->
_attributes
[
$key
]
=
$this
->
_nullObject
;
$this
->
_attributes
[
$key
]
=
$this
->
_nullObject
;
...
...
lib/Doctrine/Connection.php
View file @
3cd4fc55
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#use Doctrine::DBAL::Exceptions::ConnectionException;
#use Doctrine::DBAL::Exceptions::ConnectionException;
/**
/**
* A thin
connection wrapper on top of PDO
.
* A thin
wrapper on top of the PDO class
.
*
*
* 1. Event listeners
* 1. Event listeners
* An easy to use, pluggable eventlistener architecture. Aspects such as
* An easy to use, pluggable eventlistener architecture. Aspects such as
...
@@ -117,9 +117,9 @@ abstract class Doctrine_Connection
...
@@ -117,9 +117,9 @@ abstract class Doctrine_Connection
protected
$_quoteIdentifiers
;
protected
$_quoteIdentifiers
;
/**
/**
* @var array
$serverInfo
* @var array
*/
*/
protected
$serverInfo
=
array
();
protected
$
_
serverInfo
=
array
();
/**
/**
* The parameters used during creation of the Connection.
* The parameters used during creation of the Connection.
...
@@ -154,12 +154,19 @@ abstract class Doctrine_Connection
...
@@ -154,12 +154,19 @@ abstract class Doctrine_Connection
protected
$_platform
;
protected
$_platform
;
/**
/**
*
Enter description here..
.
*
The transaction object
.
*
*
* @var Doctrine::DBAL::Transactions::Transaction
* @var Doctrine::DBAL::Transactions::Transaction
*/
*/
protected
$_transaction
;
protected
$_transaction
;
/**
* The sequence manager.
*
* @var Doctrine::DBAL::Sequencing::SequenceManager
*/
protected
$_sequenceManager
;
/**
/**
* Constructor.
* Constructor.
* Creates a new Connection.
* Creates a new Connection.
...
@@ -339,20 +346,13 @@ abstract class Doctrine_Connection
...
@@ -339,20 +346,13 @@ abstract class Doctrine_Connection
*
*
* @return string
* @return string
* @todo make abstract, implement in subclasses.
* @todo make abstract, implement in subclasses.
* @todo throw different exception?
*/
*/
protected
function
_constructPdoDsn
()
protected
function
_constructPdoDsn
()
{
{
throw
Doctrine_Exception
::
notImplemented
(
'_constructPdoDsn'
,
get_class
(
$this
));
throw
Doctrine_Exception
::
notImplemented
(
'_constructPdoDsn'
,
get_class
(
$this
));
}
}
/**
* @todo Remove. Breaks encapsulation.
*/
public
function
incrementQueryCount
()
{
$this
->
_queryCount
++
;
}
/**
/**
* Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT
* Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT
* query, except that if there is already a row in the table with the same
* query, except that if there is already a row in the table with the same
...
@@ -360,8 +360,8 @@ abstract class Doctrine_Connection
...
@@ -360,8 +360,8 @@ abstract class Doctrine_Connection
* inserting a new row.
* inserting a new row.
*
*
* The REPLACE type of query does not make part of the SQL standards. Since
* The REPLACE type of query does not make part of the SQL standards. Since
* practically only MySQL and SQL
I
te implement it natively, this type of
* practically only MySQL and SQL
i
te implement it natively, this type of
* query isemulated through this method for other DBMS using standard types
* query is
emulated through this method for other DBMS using standard types
* of queries inside a transaction to assure the atomicity of the operation.
* of queries inside a transaction to assure the atomicity of the operation.
*
*
* @param string name of the table on which the REPLACE query will
* @param string name of the table on which the REPLACE query will
...
@@ -490,7 +490,7 @@ abstract class Doctrine_Connection
...
@@ -490,7 +490,7 @@ abstract class Doctrine_Connection
// column names are specified as array keys
// column names are specified as array keys
$cols
=
array
();
$cols
=
array
();
// the query VALUES will contain either expresions (eg 'NOW()') or ?
// the query VALUES will contain either expres
s
ions (eg 'NOW()') or ?
$a
=
array
();
$a
=
array
();
foreach
(
$data
as
$columnName
=>
$value
)
{
foreach
(
$data
as
$columnName
=>
$value
)
{
$cols
[]
=
$this
->
quoteIdentifier
(
$columnName
);
$cols
[]
=
$this
->
quoteIdentifier
(
$columnName
);
...
@@ -502,13 +502,10 @@ abstract class Doctrine_Connection
...
@@ -502,13 +502,10 @@ abstract class Doctrine_Connection
}
}
}
}
// build the statement
$query
=
'INSERT INTO '
.
$this
->
quoteIdentifier
(
$tableName
)
$query
=
'INSERT INTO '
.
$this
->
quoteIdentifier
(
$tableName
)
.
' ('
.
implode
(
', '
,
$cols
)
.
') '
.
' ('
.
implode
(
', '
,
$cols
)
.
') '
.
'VALUES ('
;
.
'VALUES ('
;
$query
.=
implode
(
', '
,
$a
)
.
')'
;
$query
.=
implode
(
', '
,
$a
)
.
')'
;
// prepare and execute the statement
return
$this
->
exec
(
$query
,
array_values
(
$data
));
return
$this
->
exec
(
$query
,
array_values
(
$data
));
}
}
...
@@ -567,14 +564,15 @@ abstract class Doctrine_Connection
...
@@ -567,14 +564,15 @@ abstract class Doctrine_Connection
// quick fix for the identifiers that contain a dot
// quick fix for the identifiers that contain a dot
if
(
strpos
(
$str
,
'.'
))
{
if
(
strpos
(
$str
,
'.'
))
{
$e
=
explode
(
'.'
,
$str
);
$e
=
explode
(
'.'
,
$str
);
return
$this
->
quoteIdentifier
(
$e
[
0
])
.
'.'
return
$this
->
quoteIdentifier
(
$e
[
0
])
.
'.'
.
$this
->
quoteIdentifier
(
$e
[
1
]);
.
$this
->
quoteIdentifier
(
$e
[
1
]);
}
}
$
q
=
$this
->
properties
[
'identifier_quoting'
]
;
$
c
=
$this
->
_platform
->
getIdentifierQuoteCharacter
()
;
$str
=
str_replace
(
$
q
[
'end'
],
$q
[
'escape'
]
.
$q
[
'end'
]
,
$str
);
$str
=
str_replace
(
$
c
,
$c
.
$c
,
$str
);
return
$
q
[
'start'
]
.
$str
.
$q
[
'end'
]
;
return
$
c
.
$str
.
$c
;
}
}
/**
/**
...
@@ -603,55 +601,16 @@ abstract class Doctrine_Connection
...
@@ -603,55 +601,16 @@ abstract class Doctrine_Connection
}
}
/**
/**
* Quotes given input parameter
* Quotes given input parameter
.
*
*
* @param mixed $input
parameter to be quoted
* @param mixed $input
Parameter to be quoted.
* @param string $type
* @param string $type
Type of the parameter.
* @return
mixed
* @return
string The quoted parameter.
*/
*/
public
function
quote
(
$input
,
$type
=
null
)
public
function
quote
(
$input
,
$type
=
null
)
{
{
return
$this
->
_pdo
->
quote
(
$input
,
$type
);
return
$this
->
_pdo
->
quote
(
$input
,
$type
);
}
}
/**
* quote
* quotes given input parameter
*
* @param mixed $input parameter to be quoted
* @param string $type
* @return mixed
*/
/*public function quote($input, $type = null)
{
if ($type == null) {
$type = gettype($input);
}
switch ($type) {
case 'integer':
case 'enum':
case 'boolean':
case 'double':
case 'float':
case 'bool':
case 'decimal':
case 'int':
return $input;
case 'array':
case 'object':
$input = serialize($input);
case 'date':
case 'time':
case 'timestamp':
case 'string':
case 'char':
case 'varchar':
case 'text':
case 'gzip':
case 'blob':
case 'clob':
return $this->conn->quote($input);
}
}*/
/**
/**
* Set the date/time format for the current connection
* Set the date/time format for the current connection
...
@@ -883,20 +842,13 @@ abstract class Doctrine_Connection
...
@@ -883,20 +842,13 @@ abstract class Doctrine_Connection
*/
*/
public
function
rethrowException
(
Exception
$e
,
$invoker
)
public
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
());
if
(
!
is_array
(
$e
->
errorInfo
))
{
if
(
!
is_array
(
$e
->
errorInfo
))
{
$e
->
errorInfo
=
array
(
null
,
null
,
null
,
null
);
$e
->
errorInfo
=
array
(
null
,
null
,
null
,
null
);
}
}
$exc
->
processErrorInfo
(
$e
->
errorInfo
);
$exc
->
processErrorInfo
(
$e
->
errorInfo
);
throw
$exc
;
throw
$exc
;
//$this->getListener()->postError($event);
}
}
/**
/**
...
@@ -1007,7 +959,7 @@ abstract class Doctrine_Connection
...
@@ -1007,7 +959,7 @@ abstract class Doctrine_Connection
*/
*/
public
function
commit
(
$savepoint
=
null
)
public
function
commit
(
$savepoint
=
null
)
{
{
return
$this
->
transaction
->
commit
(
$savepoint
);
return
$this
->
_
transaction
->
commit
(
$savepoint
);
}
}
/**
/**
...
@@ -1025,7 +977,7 @@ abstract class Doctrine_Connection
...
@@ -1025,7 +977,7 @@ abstract class Doctrine_Connection
*/
*/
public
function
rollback
(
$savepoint
=
null
)
public
function
rollback
(
$savepoint
=
null
)
{
{
$this
->
transaction
->
rollback
(
$savepoint
);
$this
->
_
transaction
->
rollback
(
$savepoint
);
}
}
/**
/**
...
@@ -1202,31 +1154,18 @@ abstract class Doctrine_Connection
...
@@ -1202,31 +1154,18 @@ abstract class Doctrine_Connection
return
Doctrine_Lib
::
getConnectionAsString
(
$this
);
return
Doctrine_Lib
::
getConnectionAsString
(
$this
);
}
}
/*
* ----------- Mixed methods (need to figure out where they go) ---------------
*/
/**
/**
* retrieves a database connection attribute
* Gets the SequenceManager that can be used to retrieve sequence values
* through this connection.
*
*
* @param integer $attribute
* @return Doctrine::DBAL::Sequencing::SequenceManager
* @return mixed
* @todo Implementation or remove if not needed. Configuration is the main
* container for all the attributes now.
*/
*/
public
function
getAttribute
(
$attribute
)
{
if
(
$attribute
==
Doctrine
::
ATTR_QUOTE_IDENTIFIER
)
{
return
false
;
}
}
public
function
getSequenceManager
()
public
function
getSequenceManager
()
{
{
if
(
!
$this
->
modules
[
'sequence'
]
)
{
if
(
!
$this
->
_sequenceManager
)
{
$class
=
"Doctrine_Sequence_"
.
$this
->
_driverName
;
$class
=
"Doctrine_Sequence_"
.
$this
->
_driverName
;
$this
->
modules
[
'sequence'
]
=
new
$class
;
$this
->
_sequenceManager
=
new
$class
;
}
}
return
$this
->
modules
[
'sequence'
]
;
return
$this
->
_sequenceManager
;
}
}
}
}
lib/Doctrine/Connection/Mock.php
View file @
3cd4fc55
...
@@ -59,6 +59,9 @@ class Doctrine_Connection_Mock extends Doctrine_Connection_Common
...
@@ -59,6 +59,9 @@ class Doctrine_Connection_Mock extends Doctrine_Connection_Common
public
function
quote
(
$input
,
$type
=
null
)
public
function
quote
(
$input
,
$type
=
null
)
{
{
if
(
$type
===
'string'
)
{
return
"'"
.
$input
.
"'"
;
}
return
$input
;
return
$input
;
}
}
}
}
\ No newline at end of file
lib/Doctrine/Connection/Statement.php
View file @
3cd4fc55
...
@@ -18,12 +18,10 @@
...
@@ -18,12 +18,10 @@
* and is licensed under the LGPL. For more information, see
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.phpdoctrine.org>.
*/
*/
Doctrine
::
autoload
(
'Doctrine_Adapter_Statement_Interface'
);
/**
/**
*
Doctrine_Connection_Statement
*
A thin wrapper around PDOStatement.
*
*
* @package Doctrine
* @subpackage Connection
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @link www.phpdoctrine.org
...
@@ -31,7 +29,7 @@ Doctrine::autoload('Doctrine_Adapter_Statement_Interface');
...
@@ -31,7 +29,7 @@ Doctrine::autoload('Doctrine_Adapter_Statement_Interface');
* @version $Revision: 1532 $
* @version $Revision: 1532 $
* @todo Do we seriously need this wrapper?
* @todo Do we seriously need this wrapper?
*/
*/
class
Doctrine_Connection_Statement
implements
Doctrine_Adapter_Statement_Interface
class
Doctrine_Connection_Statement
{
{
/**
/**
* @var Doctrine_Connection $conn Doctrine_Connection object, every connection
* @var Doctrine_Connection $conn Doctrine_Connection object, every connection
...
@@ -40,7 +38,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -40,7 +38,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
protected
$_conn
;
protected
$_conn
;
/**
/**
* @var
mixed
$_stmt PDOStatement object, boolean false or Doctrine_Adapter_Statement object
* @var
PDOStatement
$_stmt PDOStatement object, boolean false or Doctrine_Adapter_Statement object
*/
*/
protected
$_stmt
;
protected
$_stmt
;
...
@@ -81,7 +79,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -81,7 +79,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* bindColumn
* Bind a column to a PHP variable
* Bind a column to a PHP variable
*
*
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
...
@@ -125,7 +122,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -125,7 +122,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* bindParam
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(),
* SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* the variable is bound as a reference and will only be evaluated at the time
...
@@ -161,7 +157,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -161,7 +157,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* closeCursor
* Closes the cursor, enabling the statement to be executed again.
* Closes the cursor, enabling the statement to be executed again.
*
*
* @return boolean Returns TRUE on success or FALSE on failure.
* @return boolean Returns TRUE on success or FALSE on failure.
...
@@ -172,7 +167,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -172,7 +167,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* columnCount
* Returns the number of columns in the result set
* Returns the number of columns in the result set
*
*
* @return integer Returns the number of columns in the result set represented
* @return integer Returns the number of columns in the result set represented
...
@@ -185,7 +179,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -185,7 +179,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* errorCode
* Fetch the SQLSTATE associated with the last operation on the statement handle
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
*
* @see Doctrine_Adapter_Interface::errorCode()
* @see Doctrine_Adapter_Interface::errorCode()
...
@@ -197,7 +190,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -197,7 +190,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* errorInfo
* Fetch extended error information associated with the last operation on the statement handle
* Fetch extended error information associated with the last operation on the statement handle
*
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @see Doctrine_Adapter_Interface::errorInfo()
...
@@ -209,7 +201,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -209,7 +201,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* execute
* Executes a prepared statement
* Executes a prepared statement
*
*
* If the prepared statement included parameter markers, you must either:
* If the prepared statement included parameter markers, you must either:
...
@@ -226,23 +217,21 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -226,23 +217,21 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
public
function
execute
(
$params
=
null
)
public
function
execute
(
$params
=
null
)
{
{
try
{
try
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
STMT_EXECUTE
,
$this
->
getQuery
(),
$params
);
//
$event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
$this
->
_conn
->
getListener
()
->
preStmtExecute
(
$event
);
//
$this->_conn->getListener()->preStmtExecute($event);
$result
=
true
;
$result
=
true
;
if
(
!
$event
->
skipOperation
)
{
//
if ( ! $event->skipOperation) {
$result
=
$this
->
_stmt
->
execute
(
$params
);
$result
=
$this
->
_stmt
->
execute
(
$params
);
$this
->
_conn
->
incrementQueryCount
();
//
$this->_conn->incrementQueryCount();
}
//
}
$this
->
_conn
->
getListener
()
->
postStmtExecute
(
$event
);
//
$this->_conn->getListener()->postStmtExecute($event);
return
$result
;
return
$result
;
}
catch
(
PDOException
$e
)
{
}
catch
(
PDOException
$e
)
{
}
catch
(
Doctrine_Adapter_Exception
$e
)
{
}
$this
->
_conn
->
rethrowException
(
$e
,
$this
);
$this
->
_conn
->
rethrowException
(
$e
,
$this
);
}
return
false
;
return
false
;
}
}
...
@@ -278,25 +267,23 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -278,25 +267,23 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
$cursorOrientation
=
Doctrine
::
FETCH_ORI_NEXT
,
$cursorOrientation
=
Doctrine
::
FETCH_ORI_NEXT
,
$cursorOffset
=
null
)
$cursorOffset
=
null
)
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
STMT_FETCH
,
$this
->
getQuery
());
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCH, $this->getQuery());
//$event->fetchMode = $fetchMode;
//$event->cursorOrientation = $cursorOrientation;
//$event->cursorOffset = $cursorOffset;
$event
->
fetchMode
=
$fetchMode
;
//$data = $this->_conn->getListener()->preFetch($event);
$event
->
cursorOrientation
=
$cursorOrientation
;
$event
->
cursorOffset
=
$cursorOffset
;
$data
=
$this
->
_conn
->
getListener
()
->
preFetch
(
$event
);
//if ( ! $event->skipOperation) {
if
(
!
$event
->
skipOperation
)
{
$data
=
$this
->
_stmt
->
fetch
(
$fetchMode
,
$cursorOrientation
,
$cursorOffset
);
$data
=
$this
->
_stmt
->
fetch
(
$fetchMode
,
$cursorOrientation
,
$cursorOffset
);
}
//
}
$this
->
_conn
->
getListener
()
->
postFetch
(
$event
);
//
$this->_conn->getListener()->postFetch($event);
return
$data
;
return
$data
;
}
}
/**
/**
* fetchAll
* Returns an array containing all of the result set rows
* Returns an array containing all of the result set rows
*
*
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* @param integer $fetchMode Controls how the next row will be returned to the caller.
...
@@ -308,32 +295,28 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -308,32 +295,28 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
*
*
* @return array
* @return array
*/
*/
public
function
fetchAll
(
$fetchMode
=
Doctrine
::
FETCH_BOTH
,
public
function
fetchAll
(
$fetchMode
=
Doctrine
::
FETCH_BOTH
,
$columnIndex
=
null
)
$columnIndex
=
null
)
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
STMT_FETCHALL
,
$this
->
getQuery
());
//$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCHALL, $this->getQuery());
$event
->
fetchMode
=
$fetchMode
;
//$event->fetchMode = $fetchMode;
$event
->
columnIndex
=
$columnIndex
;
//$event->columnIndex = $columnIndex;
//$this->_conn->getListener()->preFetchAll($event);
$this
->
_conn
->
getListener
()
->
preFetchAll
(
$event
);
if
(
!
$event
->
skipOperation
)
{
//
if ( ! $event->skipOperation) {
if
(
$columnIndex
!==
null
)
{
if
(
$columnIndex
!==
null
)
{
$data
=
$this
->
_stmt
->
fetchAll
(
$fetchMode
,
$columnIndex
);
$data
=
$this
->
_stmt
->
fetchAll
(
$fetchMode
,
$columnIndex
);
}
else
{
}
else
{
$data
=
$this
->
_stmt
->
fetchAll
(
$fetchMode
);
$data
=
$this
->
_stmt
->
fetchAll
(
$fetchMode
);
}
}
//$event->data = $data;
//}
$event
->
data
=
$data
;
//$this->_conn->getListener()->postFetchAll($event);
}
$this
->
_conn
->
getListener
()
->
postFetchAll
(
$event
);
return
$data
;
return
$data
;
}
}
/**
/**
* fetchColumn
* Returns a single column from the next row of a
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
* result set or FALSE if there are no more rows.
*
*
...
@@ -349,7 +332,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -349,7 +332,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* fetchObject
* Fetches the next row and returns it as an object.
* Fetches the next row and returns it as an object.
*
*
* Fetches the next row and returns it as an object. This function is an alternative to
* Fetches the next row and returns it as an object. This function is an alternative to
...
@@ -367,7 +349,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -367,7 +349,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* getAttribute
* Retrieve a statement attribute
* Retrieve a statement attribute
*
*
* @param integer $attribute
* @param integer $attribute
...
@@ -380,7 +361,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -380,7 +361,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* getColumnMeta
* Returns metadata for a column in a result set
* Returns metadata for a column in a result set
*
*
* @param integer $column The 0-indexed column in the result set.
* @param integer $column The 0-indexed column in the result set.
...
@@ -401,7 +381,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -401,7 +381,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* nextRowset
* Advances to the next rowset in a multi-rowset statement handle
* Advances to the next rowset in a multi-rowset statement handle
*
*
* Some database servers support stored procedures that return more than one rowset
* Some database servers support stored procedures that return more than one rowset
...
@@ -417,7 +396,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -417,7 +396,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* rowCount
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
* executed by the corresponding object.
*
*
...
@@ -434,7 +412,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -434,7 +412,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* setAttribute
* Set a statement attribute
* Set a statement attribute
*
*
* @param integer $attribute
* @param integer $attribute
...
@@ -447,7 +424,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -447,7 +424,6 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
}
}
/**
/**
* setFetchMode
* Set the default fetch mode for this statement
* Set the default fetch mode for this statement
*
*
* @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
* @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
...
...
lib/Doctrine/DatabasePlatform.php
View file @
3cd4fc55
...
@@ -12,64 +12,62 @@
...
@@ -12,64 +12,62 @@
abstract
class
Doctrine_DatabasePlatform
abstract
class
Doctrine_DatabasePlatform
{
{
/**
/**
* An array containing all features this platform supports, keys representing feature
* Constructor.
* names and values as one of the following (true, false, 'emulated').
*/
*
* @var array
*/
protected
$_supported
=
array
();
/**
* Platform specific properties. Subclasses can override these in the
* constructor.
*
* @var array $properties
*/
protected
$_properties
=
array
(
'sql_comments'
=>
array
(
array
(
'start'
=>
'--'
,
'end'
=>
"
\n
"
,
'escape'
=>
false
),
array
(
'start'
=>
'/*'
,
'end'
=>
'*/'
,
'escape'
=>
false
)
),
'identifier_quoting'
=>
array
(
'start'
=>
'"'
,
'end'
=>
'"'
,
'escape'
=>
'"'
),
'string_quoting'
=>
array
(
'start'
=>
"'"
,
'end'
=>
"'"
,
'escape'
=>
false
,
'escape_pattern'
=>
false
),
'wildcards'
=>
array
(
'%'
,
'_'
),
'varchar_max_length'
=>
255
,
);
public
function
__construct
()
{}
public
function
__construct
()
{}
/**
/**
* Checks whether a certain feature is supported.
* Gets the character used for identifier quoting.
*
* @return string
*/
public
function
getIdentifierQuoteCharacter
()
{
return
'"'
;
}
/**
* Gets the string portion that starts an SQL comment.
*
* @return string
*/
public
function
getSqlCommentStartString
()
{
return
"--"
;
}
/**
* Gets the string portion that starts an SQL comment.
*
* @return string
*/
public
function
getSqlCommentEndString
()
{
return
"
\n
"
;
}
/**
* Gets the maximum length of a varchar field.
*
* @return integer
*/
public
function
getVarcharMaxLength
()
{
return
255
;
}
/**
* Gets all SQL wildcard characters of the platform.
*
*
* @param string $feature the name of the feature
* @return array
* @return boolean whether or not this drivers supports given feature
*/
*/
public
function
supports
(
$feature
)
public
function
getWildcards
(
)
{
{
return
(
isset
(
$this
->
_supported
[
$feature
])
&&
return
array
(
'%'
,
'_'
);
(
$this
->
_supported
[
$feature
]
===
'emulated'
||
$this
->
_supported
[
$feature
]));
}
}
/**
/**
* regexp
* Returns the regular expression operator.
* returns the regular expression operator
*
*
* @return string
* @return string
*/
*/
...
@@ -889,9 +887,10 @@ abstract class Doctrine_DatabasePlatform
...
@@ -889,9 +887,10 @@ abstract class Doctrine_DatabasePlatform
*
*
* @param string $query The SQL string to write to / append to.
* @param string $query The SQL string to write to / append to.
* @return string
* @return string
* @todo Remove the ORM dependency
*/
*/
public
function
writeLimitClauseInSubquery
(
Doctrine_ClassMetadata
$rootClass
,
$query
,
public
function
writeLimitClauseInSubquery
(
Doctrine_ClassMetadata
$rootClass
,
$limit
=
false
,
$offset
=
false
)
$
query
,
$
limit
=
false
,
$offset
=
false
)
{
{
return
$this
->
modifyLimitQuery
(
$query
,
$limit
,
$offset
);
return
$this
->
modifyLimitQuery
(
$query
,
$limit
,
$offset
);
}
}
...
@@ -910,6 +909,46 @@ abstract class Doctrine_DatabasePlatform
...
@@ -910,6 +909,46 @@ abstract class Doctrine_DatabasePlatform
}
}
return
$this
->
_properties
[
$name
];
return
$this
->
_properties
[
$name
];
}
}
public
function
supportsSequences
()
{
return
false
;
}
public
function
supportsIdentityColumns
()
{
return
false
;
}
public
function
supportsIndexes
()
{
return
true
;
}
public
function
supportsTransactions
()
{
return
true
;
}
public
function
supportsSavepoints
()
{
return
true
;
}
public
function
supportsPrimaryConstraints
()
{
return
true
;
}
public
function
supportsForeignKeyConstraints
()
{
return
true
;
}
public
function
supportsGettingAffectedRows
()
{
return
true
;
}
}
}
...
...
lib/Doctrine/DatabasePlatform/FirebirdPlatform.php
View file @
3cd4fc55
...
@@ -16,26 +16,6 @@ class Doctrine_DatabasePlatform_FirebirdPlatform extends Doctrine_DatabasePlatfo
...
@@ -16,26 +16,6 @@ class Doctrine_DatabasePlatform_FirebirdPlatform extends Doctrine_DatabasePlatfo
public
function
__construct
()
public
function
__construct
()
{
{
parent
::
__construct
();
parent
::
__construct
();
$this
->
_supported
=
array
(
'sequences'
=>
true
,
'indexes'
=>
true
,
'affected_rows'
=>
true
,
'summary_functions'
=>
true
,
'order_by_text'
=>
true
,
'transactions'
=>
true
,
'savepoints'
=>
true
,
'current_id'
=>
true
,
'limit_queries'
=>
'emulated'
,
'LOBs'
=>
true
,
'replace'
=>
'emulated'
,
'sub_selects'
=>
true
,
'auto_increment'
=>
true
,
'primary_key'
=>
true
,
'result_introspection'
=>
true
,
'prepared_statements'
=>
true
,
'identifier_quoting'
=>
false
,
'pattern_escaping'
=>
true
);
}
}
/**
/**
...
...
lib/Doctrine/DatabasePlatform/MsSqlPlatform.php
View file @
3cd4fc55
...
@@ -8,24 +8,6 @@ class Doctrine_DatabasePlatform_MsSqlPlatform extends Doctrine_DatabasePlatform
...
@@ -8,24 +8,6 @@ class Doctrine_DatabasePlatform_MsSqlPlatform extends Doctrine_DatabasePlatform
public
function
__construct
()
public
function
__construct
()
{
{
parent
::
__construct
();
parent
::
__construct
();
// initialize all driver options
$this
->
_supported
=
array
(
'sequences'
=>
'emulated'
,
'indexes'
=>
true
,
'affected_rows'
=>
true
,
'transactions'
=>
true
,
'summary_functions'
=>
true
,
'order_by_text'
=>
true
,
'current_id'
=>
'emulated'
,
'limit_queries'
=>
'emulated'
,
'LOBs'
=>
true
,
'replace'
=>
'emulated'
,
'sub_selects'
=>
true
,
'auto_increment'
=>
true
,
'primary_key'
=>
true
,
'result_introspection'
=>
true
,
'prepared_statements'
=>
'emulated'
,
);
}
}
/**
/**
...
...
lib/Doctrine/DatabasePlatform/MySqlPlatform.php
View file @
3cd4fc55
...
@@ -15,7 +15,7 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
...
@@ -15,7 +15,7 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
* @var array
* @var array
* @todo Needed? What about lazy initialization?
* @todo Needed? What about lazy initialization?
*/
*/
protected
static
$_reservedKeywords
=
array
(
/*
protected static $_reservedKeywords = array(
'ADD', 'ALL', 'ALTER',
'ADD', 'ALL', 'ALTER',
'ANALYZE', 'AND', 'AS',
'ANALYZE', 'AND', 'AS',
'ASC', 'ASENSITIVE', 'BEFORE',
'ASC', 'ASENSITIVE', 'BEFORE',
...
@@ -90,56 +90,30 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
...
@@ -90,56 +90,30 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
'WHEN', 'WHERE', 'WHILE',
'WHEN', 'WHERE', 'WHILE',
'WITH', 'WRITE', 'X509',
'WITH', 'WRITE', 'X509',
'XOR', 'YEAR_MONTH', 'ZEROFILL'
'XOR', 'YEAR_MONTH', 'ZEROFILL'
);
);*/
/**
/**
* Constructor.
* Constructor.
* Creates a new MySqlPlatform.
* Creates a new MySqlPlatform
instance
.
*/
*/
public
function
__construct
()
public
function
__construct
()
{
{
parent
::
__construct
();
parent
::
__construct
();
$this
->
_supported
=
array
(
}
'sequences'
=>
'emulated'
,
'indexes'
=>
true
,
'affected_rows'
=>
true
,
'transactions'
=>
true
,
'savepoints'
=>
false
,
'summary_functions'
=>
true
,
'order_by_text'
=>
true
,
'current_id'
=>
'emulated'
,
'limit_queries'
=>
true
,
'LOBs'
=>
true
,
'replace'
=>
true
,
'sub_selects'
=>
true
,
'auto_increment'
=>
true
,
'primary_key'
=>
true
,
'result_introspection'
=>
true
,
'prepared_statements'
=>
'emulated'
,
'identifier_quoting'
=>
true
,
'pattern_escaping'
=>
true
);
$this
->
_properties
[
'string_quoting'
]
=
array
(
'start'
=>
"'"
,
'end'
=>
"'"
,
'escape'
=>
'\\'
,
'escape_pattern'
=>
'\\'
);
$this
->
_properties
[
'identifier_quoting'
]
=
array
(
'start'
=>
'`'
,
'end'
=>
'`'
,
'escape'
=>
'`'
);
$this
->
_properties
[
'sql_comments'
]
=
array
(
array
(
'start'
=>
'-- '
,
'end'
=>
"
\n
"
,
'escape'
=>
false
),
array
(
'start'
=>
'#'
,
'end'
=>
"
\n
"
,
'escape'
=>
false
),
array
(
'start'
=>
'/*'
,
'end'
=>
'*/'
,
'escape'
=>
false
),
);
$this
->
properties
[
'varchar_max_length'
]
=
255
;
/**
* Gets the character used for identifier quoting.
*
* @return string
* @override
*/
public
function
getIdentifierQuoteCharacter
()
{
return
'`'
;
}
}
/**
/**
*
returns the regular expression operator
*
Returns the regular expression operator.
*
*
* @return string
* @return string
* @override
* @override
...
@@ -204,6 +178,7 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
...
@@ -204,6 +178,7 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
}
}
$match
.=
"'"
;
$match
.=
"'"
;
$match
.=
$this
->
patternEscapeString
();
$match
.=
$this
->
patternEscapeString
();
return
$match
;
return
$match
;
}
}
...
@@ -555,6 +530,29 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
...
@@ -555,6 +530,29 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
{
{
return
true
;
return
true
;
}
}
/**
* Whether the platform supports identity columns.
* MySql supports this through AUTO_INCREMENT columns.
*
* @return boolean
* @override
*/
public
function
supportsIdentityColumns
()
{
return
true
;
}
/**
* Whether the platform supports savepoints. MySql does not.
*
* @return boolean
* @override
*/
public
function
supportsSavepoints
()
{
return
false
;
}
}
}
?>
?>
\ No newline at end of file
lib/Doctrine/DatabasePlatform/OraclePlatform.php
View file @
3cd4fc55
...
@@ -8,26 +8,6 @@ class Doctrine_DatabasePlatform_OraclePlatform extends Doctrine_DatabasePlatform
...
@@ -8,26 +8,6 @@ class Doctrine_DatabasePlatform_OraclePlatform extends Doctrine_DatabasePlatform
public
function
__construct
()
public
function
__construct
()
{
{
parent
::
__construct
();
parent
::
__construct
();
$this
->
_supported
=
array
(
'sequences'
=>
true
,
'indexes'
=>
true
,
'summary_functions'
=>
true
,
'order_by_text'
=>
true
,
'current_id'
=>
true
,
'affected_rows'
=>
true
,
'transactions'
=>
true
,
'savepoints'
=>
true
,
'limit_queries'
=>
true
,
'LOBs'
=>
true
,
'replace'
=>
'emulated'
,
'sub_selects'
=>
true
,
'auto_increment'
=>
false
,
// implementation is broken
'primary_key'
=>
true
,
'result_introspection'
=>
true
,
'prepared_statements'
=>
true
,
'identifier_quoting'
=>
true
,
'pattern_escaping'
=>
true
,
);
}
}
/**
/**
...
@@ -44,6 +24,9 @@ class Doctrine_DatabasePlatform_OraclePlatform extends Doctrine_DatabasePlatform
...
@@ -44,6 +24,9 @@ class Doctrine_DatabasePlatform_OraclePlatform extends Doctrine_DatabasePlatform
return
$this
->
_createLimitSubquery
(
$query
,
$limit
,
$offset
);
return
$this
->
_createLimitSubquery
(
$query
,
$limit
,
$offset
);
}
}
/**
* @todo Doc
*/
private
function
_createLimitSubquery
(
$query
,
$limit
,
$offset
,
$column
=
null
)
private
function
_createLimitSubquery
(
$query
,
$limit
,
$offset
,
$column
=
null
)
{
{
$limit
=
(
int
)
$limit
;
$limit
=
(
int
)
$limit
;
...
...
lib/Doctrine/DatabasePlatform/PostgreSqlPlatform.php
View file @
3cd4fc55
...
@@ -9,7 +9,7 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
...
@@ -9,7 +9,7 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
* @param array
* @param array
* @todo Nedded? What about lazy initialization?
* @todo Nedded? What about lazy initialization?
*/
*/
protected
static
$_reservedKeywords
=
array
(
/*
protected static $_reservedKeywords = array(
'abort', 'absolute', 'access', 'action', 'add', 'after', 'aggregate',
'abort', 'absolute', 'access', 'action', 'add', 'after', 'aggregate',
'all', 'alter', 'analyse', 'analyze', 'and', 'any', 'as', 'asc',
'all', 'alter', 'analyse', 'analyze', 'and', 'any', 'as', 'asc',
'assertion', 'assignment', 'at', 'authorization', 'backward', 'before',
'assertion', 'assignment', 'at', 'authorization', 'backward', 'before',
...
@@ -54,7 +54,7 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
...
@@ -54,7 +54,7 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
'unknown', 'unlisten', 'until', 'update', 'usage', 'user', 'using',
'unknown', 'unlisten', 'until', 'update', 'usage', 'user', 'using',
'vacuum', 'valid', 'validator', 'values', 'varchar', 'varying',
'vacuum', 'valid', 'validator', 'values', 'varchar', 'varying',
'verbose', 'version', 'view', 'volatile', 'when', 'where', 'with',
'verbose', 'version', 'view', 'volatile', 'when', 'where', 'with',
'without'
,
'work'
,
'write'
,
'year'
,
'zone'
);
'without', 'work', 'write', 'year','zone');
*/
/**
/**
...
@@ -64,27 +64,6 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
...
@@ -64,27 +64,6 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
public
function
__construct
()
public
function
__construct
()
{
{
parent
::
__construct
();
parent
::
__construct
();
$this
->
_supported
=
array
(
'sequences'
=>
true
,
'indexes'
=>
true
,
'affected_rows'
=>
true
,
'summary_functions'
=>
true
,
'order_by_text'
=>
true
,
'transactions'
=>
true
,
'savepoints'
=>
true
,
'current_id'
=>
true
,
'limit_queries'
=>
true
,
'LOBs'
=>
true
,
'replace'
=>
'emulated'
,
'sub_selects'
=>
true
,
'auto_increment'
=>
'emulated'
,
'primary_key'
=>
true
,
'result_introspection'
=>
true
,
'prepared_statements'
=>
true
,
'identifier_quoting'
=>
true
,
'pattern_escaping'
=>
true
,
);
$this
->
_properties
[
'string_quoting'
]
=
array
(
'start'
=>
"'"
,
$this
->
_properties
[
'string_quoting'
]
=
array
(
'start'
=>
"'"
,
'end'
=>
"'"
,
'end'
=>
"'"
,
'escape'
=>
"'"
,
'escape'
=>
"'"
,
...
@@ -94,7 +73,6 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
...
@@ -94,7 +73,6 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
'escape'
=>
'"'
);
'escape'
=>
'"'
);
}
}
/**
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
* field to be used in statements like CREATE TABLE.
...
@@ -510,6 +488,38 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
...
@@ -510,6 +488,38 @@ class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlat
{
{
return
$value
;
return
$value
;
}
}
/**
* Whether the platform supports sequences.
* Postgres has native support for sequences.
*
* @return boolean
*/
public
function
supportsSequences
()
{
return
true
;
}
/**
* Whether the platform supports identity columns.
* Postgres supports these through the SERIAL keyword.
*
* @return boolean
*/
public
function
supportsIdentityColumns
()
{
return
true
;
}
/**
* Whether the platform prefers sequences for ID generation.
*
* @return boolean
*/
public
function
prefersSequences
()
{
return
true
;
}
}
}
?>
?>
\ No newline at end of file
lib/Doctrine/DatabasePlatform/SqlitePlatform.php
View file @
3cd4fc55
...
@@ -16,26 +16,6 @@ class Doctrine_DatabasePlatform_SqlitePlatform extends Doctrine_DatabasePlatform
...
@@ -16,26 +16,6 @@ class Doctrine_DatabasePlatform_SqlitePlatform extends Doctrine_DatabasePlatform
public
function
__construct
()
public
function
__construct
()
{
{
parent
::
__construct
();
parent
::
__construct
();
$this
->
_supported
=
array
(
'sequences'
=>
'emulated'
,
'indexes'
=>
true
,
'affected_rows'
=>
true
,
'summary_functions'
=>
true
,
'order_by_text'
=>
true
,
'current_id'
=>
'emulated'
,
'limit_queries'
=>
true
,
'LOBs'
=>
true
,
'replace'
=>
true
,
'transactions'
=>
true
,
'savepoints'
=>
false
,
'sub_selects'
=>
true
,
'auto_increment'
=>
true
,
'primary_key'
=>
true
,
'result_introspection'
=>
false
,
// not implemented
'prepared_statements'
=>
'emulated'
,
'identifier_quoting'
=>
true
,
'pattern_escaping'
=>
false
,
);
}
}
/**
/**
...
...
lib/Doctrine/Entity.php
View file @
3cd4fc55
This diff is collapsed.
Click to expand it.
lib/Doctrine/Hydrator/RecordDriver.php
View file @
3cd4fc55
...
@@ -74,7 +74,7 @@ class Doctrine_Hydrator_RecordDriver
...
@@ -74,7 +74,7 @@ class Doctrine_Hydrator_RecordDriver
$relatedClass
=
$relation
->
getTable
();
$relatedClass
=
$relation
->
getTable
();
$coll
=
$this
->
getElementCollection
(
$relatedClass
->
getClassName
());
$coll
=
$this
->
getElementCollection
(
$relatedClass
->
getClassName
());
$coll
->
setReference
(
$entity
,
$relation
);
$coll
->
setReference
(
$entity
,
$relation
);
$entity
->
_
raw
SetReference
(
$name
,
$coll
);
$entity
->
_
internal
SetReference
(
$name
,
$coll
);
$this
->
_initializedRelations
[
$entity
->
getOid
()][
$name
]
=
true
;
$this
->
_initializedRelations
[
$entity
->
getOid
()][
$name
]
=
true
;
}
}
}
}
...
@@ -97,23 +97,23 @@ class Doctrine_Hydrator_RecordDriver
...
@@ -97,23 +97,23 @@ class Doctrine_Hydrator_RecordDriver
public
function
addRelatedIndexedElement
(
Doctrine_Entity
$entity1
,
$property
,
public
function
addRelatedIndexedElement
(
Doctrine_Entity
$entity1
,
$property
,
Doctrine_Entity
$entity2
,
$indexField
)
Doctrine_Entity
$entity2
,
$indexField
)
{
{
$entity1
->
_
rawGetReference
(
$property
)
->
add
(
$entity2
,
$entity2
->
_raw
GetField
(
$indexField
));
$entity1
->
_
internalGetReference
(
$property
)
->
add
(
$entity2
,
$entity2
->
_internal
GetField
(
$indexField
));
}
}
public
function
addRelatedElement
(
Doctrine_Entity
$entity1
,
$property
,
public
function
addRelatedElement
(
Doctrine_Entity
$entity1
,
$property
,
Doctrine_Entity
$entity2
)
Doctrine_Entity
$entity2
)
{
{
$entity1
->
_
raw
GetReference
(
$property
)
->
add
(
$entity2
);
$entity1
->
_
internal
GetReference
(
$property
)
->
add
(
$entity2
);
}
}
public
function
setRelatedElement
(
Doctrine_Entity
$entity1
,
$property
,
$entity2
)
public
function
setRelatedElement
(
Doctrine_Entity
$entity1
,
$property
,
$entity2
)
{
{
$entity1
->
_
raw
SetReference
(
$property
,
$entity2
);
$entity1
->
_
internal
SetReference
(
$property
,
$entity2
);
}
}
public
function
isIndexKeyInUse
(
Doctrine_Entity
$entity
,
$assocField
,
$indexField
)
public
function
isIndexKeyInUse
(
Doctrine_Entity
$entity
,
$assocField
,
$indexField
)
{
{
return
$entity
->
_
raw
GetReference
(
$assocField
)
->
contains
(
$indexField
);
return
$entity
->
_
internal
GetReference
(
$assocField
)
->
contains
(
$indexField
);
}
}
public
function
isFieldSet
(
Doctrine_Entity
$entity
,
$field
)
public
function
isFieldSet
(
Doctrine_Entity
$entity
,
$field
)
...
@@ -123,17 +123,17 @@ class Doctrine_Hydrator_RecordDriver
...
@@ -123,17 +123,17 @@ class Doctrine_Hydrator_RecordDriver
public
function
getFieldValue
(
Doctrine_Entity
$entity
,
$field
)
public
function
getFieldValue
(
Doctrine_Entity
$entity
,
$field
)
{
{
return
$entity
->
_
raw
GetField
(
$field
);
return
$entity
->
_
internal
GetField
(
$field
);
}
}
public
function
getReferenceValue
(
Doctrine_Entity
$entity
,
$field
)
public
function
getReferenceValue
(
Doctrine_Entity
$entity
,
$field
)
{
{
return
$entity
->
_
raw
GetReference
(
$field
);
return
$entity
->
_
internal
GetReference
(
$field
);
}
}
public
function
addElementToIndexedCollection
(
$coll
,
$entity
,
$keyField
)
public
function
addElementToIndexedCollection
(
$coll
,
$entity
,
$keyField
)
{
{
$coll
->
add
(
$entity
,
$entity
->
_
raw
GetField
(
$keyField
));
$coll
->
add
(
$entity
,
$entity
->
_
internal
GetField
(
$keyField
));
}
}
public
function
addElementToCollection
(
$coll
,
$entity
)
public
function
addElementToCollection
(
$coll
,
$entity
)
...
...
lib/Doctrine/Query/Parser.php
View file @
3cd4fc55
...
@@ -165,7 +165,6 @@ class Doctrine_Query_Parser
...
@@ -165,7 +165,6 @@ class Doctrine_Query_Parser
if
(
!
$isMatch
)
{
if
(
!
$isMatch
)
{
// No definition for value checking.
// No definition for value checking.
$this
->
syntaxError
(
$this
->
_keywordTable
->
getLiteral
(
$token
));
$this
->
syntaxError
(
$this
->
_keywordTable
->
getLiteral
(
$token
));
}
}
$this
->
next
();
$this
->
next
();
...
...
lib/Doctrine/Query/Production/Atom.php
View file @
3cd4fc55
...
@@ -78,19 +78,20 @@ class Doctrine_Query_Production_Atom extends Doctrine_Query_Production
...
@@ -78,19 +78,20 @@ class Doctrine_Query_Production_Atom extends Doctrine_Query_Production
switch
(
$this
->
_type
)
{
switch
(
$this
->
_type
)
{
case
'param'
:
case
'param'
:
return
$this
->
_value
;
return
$this
->
_value
;
break
;
case
'string'
:
//FIXME: Remove the quotes from _value! Should the scanner do that or where?
case
'integer'
:
// 'mystring' => mystring. Otherwise 'mystring' is the content (with quotes)!
case
'float'
:
// Eg: select ... from ... where f.foo = 'bar'
// => $conn->quote('bar',...), CURRENTLY: $conn->quote("'bar'",...)
// This fix looks a bit ugly or ... ? Should this happen earlier? Syntax?
// Scanner?
if
(
strpos
(
$this
->
_value
,
"'"
)
===
0
)
{
$this
->
_value
=
substr
(
$this
->
_value
,
1
,
strlen
(
$this
->
_value
)
-
2
);
}
return
$conn
->
quote
(
$this
->
_value
,
$this
->
_type
);
return
$conn
->
quote
(
$this
->
_value
,
$this
->
_type
);
break
;
default
:
default
:
$stringQuoting
=
$conn
->
getDatabasePlatform
()
->
getProperty
(
'string_quoting'
);
return
$conn
->
quote
(
$this
->
_value
,
$this
->
_type
);
return
$stringQuoting
[
'start'
]
.
$conn
->
quote
(
$this
->
_value
,
$this
->
_type
)
.
$stringQuoting
[
'end'
];
break
;
}
}
}
}
...
...
lib/Doctrine/Query/Scanner.php
View file @
3cd4fc55
...
@@ -33,14 +33,18 @@
...
@@ -33,14 +33,18 @@
class
Doctrine_Query_Scanner
class
Doctrine_Query_Scanner
{
{
/**
/**
* Array of scanned tokens
* Array of scanned tokens
.
*
*
* @var array
* @var array
*/
*/
protected
$_tokens
=
array
();
protected
$_tokens
=
array
();
/**
* @todo Doc
*/
protected
$_position
=
0
;
protected
$_position
=
0
;
/**
* @todo Doc
*/
protected
$_peek
=
0
;
protected
$_peek
=
0
;
/**
/**
...
@@ -109,7 +113,9 @@ class Doctrine_Query_Scanner
...
@@ -109,7 +113,9 @@ class Doctrine_Query_Scanner
}
}
}
}
/**
* @todo Doc
*/
protected
function
_getType
(
&
$value
)
protected
function
_getType
(
&
$value
)
{
{
// $value is referenced because it can be changed if it is numeric.
// $value is referenced because it can be changed if it is numeric.
...
@@ -117,30 +123,32 @@ class Doctrine_Query_Scanner
...
@@ -117,30 +123,32 @@ class Doctrine_Query_Scanner
$type
=
Doctrine_Query_Token
::
T_NONE
;
$type
=
Doctrine_Query_Token
::
T_NONE
;
$newVal
=
$this
->
_getNumeric
(
$value
);
$newVal
=
$this
->
_getNumeric
(
$value
);
if
(
$newVal
!==
false
){
if
(
$newVal
!==
false
){
$value
=
$newVal
;
$value
=
$newVal
;
if
(
strpos
(
$value
,
'.'
)
!==
false
||
stripos
(
$value
,
'e'
)
!==
false
)
{
if
(
strpos
(
$value
,
'.'
)
!==
false
||
stripos
(
$value
,
'e'
)
!==
false
)
{
$type
=
Doctrine_Query_Token
::
T_FLOAT
;
$type
=
Doctrine_Query_Token
::
T_FLOAT
;
}
else
{
}
else
{
$type
=
Doctrine_Query_Token
::
T_INTEGER
;
$type
=
Doctrine_Query_Token
::
T_INTEGER
;
}
}
}
}
if
(
$value
[
0
]
===
"'"
&&
$value
[
strlen
(
$value
)
-
1
]
===
"'"
)
{
if
(
$value
[
0
]
===
"'"
&&
$value
[
strlen
(
$value
)
-
1
]
===
"'"
)
{
$type
=
Doctrine_Query_Token
::
T_STRING
;
$type
=
Doctrine_Query_Token
::
T_STRING
;
}
elseif
(
ctype_alpha
(
$value
[
0
])
||
$value
[
0
]
===
'_'
)
{
}
else
if
(
ctype_alpha
(
$value
[
0
])
||
$value
[
0
]
===
'_'
)
{
$type
=
$this
->
_checkLiteral
(
$value
);
$type
=
$this
->
_checkLiteral
(
$value
);
}
elseif
(
$value
[
0
]
===
'?'
||
$value
[
0
]
===
':'
)
{
}
else
if
(
$value
[
0
]
===
'?'
||
$value
[
0
]
===
':'
)
{
$type
=
Doctrine_Query_Token
::
T_INPUT_PARAMETER
;
$type
=
Doctrine_Query_Token
::
T_INPUT_PARAMETER
;
}
}
return
$type
;
return
$type
;
}
}
/**
* @todo Doc
*/
protected
function
_getNumeric
(
$value
)
protected
function
_getNumeric
(
$value
)
{
{
if
(
!
is_scalar
(
$value
))
{
if
(
!
is_scalar
(
$value
))
{
return
false
;
return
false
;
}
}
// Checking for valid numeric numbers: 1.234, -1.234e-2
// Checking for valid numeric numbers: 1.234, -1.234e-2
...
@@ -164,7 +172,9 @@ class Doctrine_Query_Scanner
...
@@ -164,7 +172,9 @@ class Doctrine_Query_Scanner
}
}
/**
* @todo Doc
*/
public
function
isA
(
$value
,
$token
)
public
function
isA
(
$value
,
$token
)
{
{
$type
=
$this
->
_getType
(
$value
);
$type
=
$this
->
_getType
(
$value
);
...
@@ -172,7 +182,9 @@ class Doctrine_Query_Scanner
...
@@ -172,7 +182,9 @@ class Doctrine_Query_Scanner
return
$type
===
$token
;
return
$type
===
$token
;
}
}
/**
* @todo Doc
*/
public
function
peek
()
public
function
peek
()
{
{
if
(
isset
(
$this
->
_tokens
[
$this
->
_position
+
$this
->
_peek
]))
{
if
(
isset
(
$this
->
_tokens
[
$this
->
_position
+
$this
->
_peek
]))
{
...
@@ -182,13 +194,14 @@ class Doctrine_Query_Scanner
...
@@ -182,13 +194,14 @@ class Doctrine_Query_Scanner
}
}
}
}
/**
* @todo Doc
*/
public
function
resetPeek
()
public
function
resetPeek
()
{
{
$this
->
_peek
=
0
;
$this
->
_peek
=
0
;
}
}
/**
/**
* Returns the next token in the input string.
* Returns the next token in the input string.
*
*
...
@@ -211,7 +224,9 @@ class Doctrine_Query_Scanner
...
@@ -211,7 +224,9 @@ class Doctrine_Query_Scanner
}
}
}
}
/**
* @todo Doc
*/
public
function
resetPosition
(
$position
=
0
)
public
function
resetPosition
(
$position
=
0
)
{
{
$this
->
_position
=
$position
;
$this
->
_position
=
$position
;
...
...
lib/Doctrine/Relation/Parser.php
View file @
3cd4fc55
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
* @link www.phpdoctrine.org
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @todo Composite key support?
* @todo Composite key support?
* @todo Remove. Association mapping needs a reimplementation.
*/
*/
class
Doctrine_Relation_Parser
class
Doctrine_Relation_Parser
{
{
...
...
lib/Doctrine/Sequence/Mysql.php
View file @
3cd4fc55
...
@@ -68,7 +68,7 @@ class Doctrine_Sequence_Mysql extends Doctrine_Sequence
...
@@ -68,7 +68,7 @@ class Doctrine_Sequence_Mysql extends Doctrine_Sequence
$query
=
'DELETE FROM '
.
$sequenceName
.
' WHERE '
.
$seqcolName
.
' < '
.
$value
;
$query
=
'DELETE FROM '
.
$sequenceName
.
' WHERE '
.
$seqcolName
.
' < '
.
$value
;
try
{
try
{
$this
->
conn
->
exec
(
$query
);
$this
->
conn
->
exec
(
$query
);
}
catch
(
Doctrine_Exception
$e
)
{
}
catch
(
Doctrine_Exception
$e
)
{
throw
new
Doctrine_Sequence_Exception
(
'could not delete previous sequence table values from '
.
$seqName
);
throw
new
Doctrine_Sequence_Exception
(
'could not delete previous sequence table values from '
.
$seqName
);
}
}
}
}
...
...
lib/Doctrine/Sequence/Oracle.php
View file @
3cd4fc55
...
@@ -40,7 +40,7 @@ class Doctrine_Sequence_Oracle extends Doctrine_Sequence
...
@@ -40,7 +40,7 @@ class Doctrine_Sequence_Oracle extends Doctrine_Sequence
*
*
* @return integer next id in the given sequence
* @return integer next id in the given sequence
*/
*/
public
function
nextI
D
(
$seqName
,
$onDemand
=
true
)
public
function
nextI
d
(
$seqName
,
$onDemand
=
true
)
{
{
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$query
=
'SELECT '
.
$sequenceName
.
'.nextval FROM DUAL'
;
$query
=
'SELECT '
.
$sequenceName
.
'.nextval FROM DUAL'
;
...
@@ -69,7 +69,7 @@ class Doctrine_Sequence_Oracle extends Doctrine_Sequence
...
@@ -69,7 +69,7 @@ class Doctrine_Sequence_Oracle extends Doctrine_Sequence
* @param string name of the table into which a new row was inserted
* @param string name of the table into which a new row was inserted
* @param string name of the field into which a new row was inserted
* @param string name of the field into which a new row was inserted
*/
*/
public
function
lastInsertI
D
(
$table
=
null
,
$field
=
null
)
public
function
lastInsertI
d
(
$table
=
null
,
$field
=
null
)
{
{
$seqName
=
$table
.
(
empty
(
$field
)
?
''
:
'_'
.
$field
);
$seqName
=
$table
.
(
empty
(
$field
)
?
''
:
'_'
.
$field
);
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
...
@@ -84,7 +84,7 @@ class Doctrine_Sequence_Oracle extends Doctrine_Sequence
...
@@ -84,7 +84,7 @@ class Doctrine_Sequence_Oracle extends Doctrine_Sequence
*
*
* @return integer current id in the given sequence
* @return integer current id in the given sequence
*/
*/
public
function
currI
D
(
$seqName
)
public
function
currI
d
(
$seqName
)
{
{
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$query
=
'SELECT (last_number-1) FROM user_sequences'
;
$query
=
'SELECT (last_number-1) FROM user_sequences'
;
...
...
tests/Orm/Entity/AccessorTest.php
View file @
3cd4fc55
...
@@ -13,8 +13,6 @@ class Orm_Entity_AccessorTest extends Doctrine_OrmTestCase
...
@@ -13,8 +13,6 @@ class Orm_Entity_AccessorTest extends Doctrine_OrmTestCase
$entity2
->
username
=
'romanb'
;
$entity2
->
username
=
'romanb'
;
$this
->
assertEquals
(
'romanb?!'
,
$entity1
->
username
);
$this
->
assertEquals
(
'romanb?!'
,
$entity1
->
username
);
}
}
}
}
...
@@ -41,12 +39,12 @@ class CustomAccessorMutatorTestEntity extends Doctrine_Entity
...
@@ -41,12 +39,12 @@ class CustomAccessorMutatorTestEntity extends Doctrine_Entity
public
function
getUsernameCustom
()
public
function
getUsernameCustom
()
{
{
return
$this
->
_
rawGetField
(
'username'
)
.
"!"
;
return
$this
->
_
get
(
'username'
)
.
"!"
;
}
}
public
function
setUsernameCustom
(
$username
)
public
function
setUsernameCustom
(
$username
)
{
{
$this
->
_
rawSetField
(
'username'
,
$username
.
"?"
);
$this
->
_
set
(
'username'
,
$username
.
"?"
);
}
}
}
}
...
@@ -69,11 +67,11 @@ class MagicAccessorMutatorTestEntity extends Doctrine_Entity
...
@@ -69,11 +67,11 @@ class MagicAccessorMutatorTestEntity extends Doctrine_Entity
public
function
getUsername
()
public
function
getUsername
()
{
{
return
$this
->
_
rawGetField
(
'username'
)
.
"!"
;
return
$this
->
_
get
(
'username'
)
.
"!"
;
}
}
public
function
setUsername
(
$username
)
public
function
setUsername
(
$username
)
{
{
$this
->
_
rawSetField
(
'username'
,
$username
.
"?"
);
$this
->
_
set
(
'username'
,
$username
.
"?"
);
}
}
}
}
\ No newline at end of file
tests/Orm/Query/SelectSqlGenerationTest.php
View file @
3cd4fc55
...
@@ -134,7 +134,9 @@ class Orm_Query_SelectSqlGenerationTest extends Doctrine_OrmTestCase
...
@@ -134,7 +134,9 @@ class Orm_Query_SelectSqlGenerationTest extends Doctrine_OrmTestCase
{
{
$this
->
assertSqlGeneration
(
$this
->
assertSqlGeneration
(
"SELECT u.name FROM CmsUser u WHERE TRIM(u.name) = 'someone'"
,
"SELECT u.name FROM CmsUser u WHERE TRIM(u.name) = 'someone'"
,
"SELECT cu.name AS cu__name FROM cms_user cu WHERE TRIM(cu.name) = ''someone''"
// SQLite double slashes for strings
// String quoting in the SQL usually depends on the database platform.
// This test works with a mock connection which uses ' for string quoting.
"SELECT cu.name AS cu__name FROM cms_user cu WHERE TRIM(cu.name) = 'someone'"
);
);
}
}
...
...
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