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
b7ab7229
Commit
b7ab7229
authored
Jan 24, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
4faa6e54
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
44 deletions
+160
-44
Configurable.php
lib/Doctrine/Configurable.php
+1
-0
Connection.php
lib/Doctrine/Connection.php
+32
-10
Oracle.php
lib/Doctrine/Import/Oracle.php
+27
-19
DriverTestCase.php
tests/DriverTestCase.php
+2
-2
OracleTestCase.php
tests/Import/OracleTestCase.php
+73
-1
PgsqlTestCase.php
tests/Import/PgsqlTestCase.php
+2
-1
TreeStructureTestCase.php
tests/TreeStructureTestCase.php
+11
-1
run.php
tests/run.php
+12
-10
No files found.
lib/Doctrine/Configurable.php
View file @
b7ab7229
...
...
@@ -126,6 +126,7 @@ abstract class Doctrine_Configurable
case
Doctrine
::
ATTR_DEFAULT_TABLE_TYPE
:
case
Doctrine
::
ATTR_ACCESSOR_PREFIX_GET
:
case
Doctrine
::
ATTR_ACCESSOR_PREFIX_SET
:
case
Doctrine
::
ATTR_EMULATE_DATABASE
:
break
;
case
Doctrine
::
ATTR_SEQCOL_NAME
:
...
...
lib/Doctrine/Connection.php
View file @
b7ab7229
...
...
@@ -497,7 +497,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public
function
fetchAll
(
$statement
,
array
$params
=
array
())
{
public
function
fetchAll
(
$statement
,
array
$params
=
array
())
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
/**
...
...
@@ -508,7 +509,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param int $colnum 0-indexed column number to retrieve
* @return mixed
*/
public
function
fetchOne
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
{
public
function
fetchOne
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetchColumn
(
$colnum
);
}
/**
...
...
@@ -518,7 +520,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public
function
fetchRow
(
$statement
,
array
$params
=
array
())
{
public
function
fetchRow
(
$statement
,
array
$params
=
array
())
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetch
(
PDO
::
FETCH_ASSOC
);
}
/**
...
...
@@ -528,7 +531,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public
function
fetchArray
(
$statement
,
array
$params
=
array
())
{
public
function
fetchArray
(
$statement
,
array
$params
=
array
())
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetch
(
PDO
::
FETCH_NUM
);
}
/**
...
...
@@ -539,7 +543,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param int $colnum 0-indexed column number to retrieve
* @return array
*/
public
function
fetchColumn
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
{
public
function
fetchColumn
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetchAll
(
PDO
::
FETCH_COLUMN
,
$colnum
);
}
/**
...
...
@@ -549,7 +554,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public
function
fetchAssoc
(
$statement
,
array
$params
=
array
())
{
public
function
fetchAssoc
(
$statement
,
array
$params
=
array
())
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
/**
...
...
@@ -559,7 +565,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params prepared statement params
* @return array
*/
public
function
fetchBoth
(
$statement
,
array
$params
=
array
())
{
public
function
fetchBoth
(
$statement
,
array
$params
=
array
())
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetchAll
(
PDO
::
FETCH_BOTH
);
}
/**
...
...
@@ -578,7 +585,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @see Doctrine_Query
* @return Doctrine_Collection Collection of Doctrine_Record objects
*/
public
function
query
(
$query
,
array
$params
=
array
())
{
public
function
query
(
$query
,
array
$params
=
array
())
{
$parser
=
new
Doctrine_Query
(
$this
);
return
$parser
->
query
(
$query
,
$params
);
...
...
@@ -602,7 +610,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @return Doctrine_Record|false Doctrine_Record object on success,
* boolean false on failure
*/
public
function
queryOne
(
$query
,
array
$params
=
array
())
{
public
function
queryOne
(
$query
,
array
$params
=
array
())
{
$parser
=
new
Doctrine_Query
(
$this
);
$coll
=
$parser
->
query
(
$query
,
$params
);
...
...
@@ -627,6 +636,18 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
return
$this
->
dbh
->
query
(
$query
);
}
/**
* standaloneQuery
*
* @param string $query sql query
* @param array $params query parameters
*
* @return PDOStatement|Doctrine_Adapter_Statement
*/
public
function
standaloneQuery
(
$query
,
$params
=
array
())
{
return
$this
->
execute
(
$query
,
$params
);
}
/**
* execute
* @param string $query sql query
...
...
@@ -634,7 +655,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @return PDOStatement|Doctrine_Adapter_Statement
*/
public
function
execute
(
$query
,
array
$params
=
array
())
{
public
function
execute
(
$query
,
array
$params
=
array
())
{
try
{
if
(
!
empty
(
$params
))
{
$stmt
=
$this
->
dbh
->
prepare
(
$query
);
...
...
lib/Doctrine/Import/Oracle.php
View file @
b7ab7229
...
...
@@ -37,23 +37,22 @@ class Doctrine_Import_Oracle extends Doctrine_Import
*/
public
function
listDatabases
()
{
if
(
!
$this
->
conn
->
options
[
'emulate_database'
])
{
return
$this
->
conn
->
raiseError
(
Doctrine
::
ERROR_UNSUPPORTED
,
null
,
null
,
'database listing is only supported if the "emulate_database" option is enabled'
,
__FUNCTION__
);
if
(
!
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_EMULATE_DATABASE
))
{
throw
new
Doctrine_Import_Exception
(
'database listing is only supported if the "emulate_database" option is enabled'
);
}
/**
if ($this->conn->options['database_name_prefix']) {
$query = 'SELECT SUBSTR(username, ';
$query
.=
(
strlen
(
$this
->
conn
->
options
[
'database_name_prefix'
])
+
1
);
$query.= (strlen($this->conn->
getAttribute(
['database_name_prefix'])+1);
$query.= ") FROM sys.dba_users WHERE username LIKE '";
$query.= $this->conn->options['database_name_prefix']."%'";
} else {
$query
=
'SELECT username FROM sys.dba_users'
;
}
$result2
=
$this
->
conn
->
standaloneQuery
(
$query
,
array
(
'text'
),
false
);
$result
=
$result2
->
fetchCol
();
*/
$query
=
'SELECT username FROM sys.dba_users'
;
$result2
=
$this
->
conn
->
standaloneQuery
(
$query
);
$result
=
$result2
->
fetchColumn
();
$result2
->
free
();
return
$result
;
}
/**
...
...
@@ -86,6 +85,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
public
function
listSequences
(
$database
=
null
)
{
$query
=
"SELECT sequence_name FROM sys.user_sequences"
;
$tableNames
=
$this
->
conn
->
fetchColumn
(
$query
);
return
array_map
(
array
(
$this
->
conn
,
'fixSequenceName'
),
$tableNames
);
...
...
@@ -98,10 +98,11 @@ class Doctrine_Import_Oracle extends Doctrine_Import
*/
public
function
listTableConstraints
(
$table
)
{
$table
=
$this
->
conn
->
quote
(
$table
,
'text'
);
$query
=
'SELECT index_name name FROM user_constraints'
;
$query
.=
' WHERE table_name='
.
$table
.
' OR table_name='
.
strtoupper
(
$table
);
$query
=
'SELECT index_name name FROM user_constraints'
.
' WHERE table_name = '
.
$table
.
' OR table_name = '
.
strtoupper
(
$table
);
$constraints
=
$this
->
conn
->
fetchColumn
(
$query
);
return
array_map
(
array
(
$this
->
conn
,
'fixIndexName'
),
$constraints
);
...
...
@@ -115,7 +116,9 @@ class Doctrine_Import_Oracle extends Doctrine_Import
public
function
listTableColumns
(
$table
)
{
$table
=
strtoupper
(
$table
);
$sql
=
"SELECT column_name, data_type, data_length, nullable, data_default from all_tab_columns WHERE table_name='
$table
' ORDER BY column_name"
;
$sql
=
"SELECT column_name, data_type, data_length, nullable, data_default from all_tab_columns"
.
" WHERE table_name = '"
.
$table
.
"' ORDER BY column_name"
;
$result
=
$this
->
conn
->
fetchAssoc
(
$sql
);
foreach
(
$result
as
$val
)
{
...
...
@@ -138,9 +141,10 @@ class Doctrine_Import_Oracle extends Doctrine_Import
public
function
listTableIndexes
(
$table
)
{
$table
=
$this
->
conn
->
quote
(
$table
,
'text'
);
$query
=
'SELECT index_name name FROM user_indexes'
;
$query
.=
' WHERE table_name='
.
$table
.
' OR table_name='
.
strtoupper
(
$table
);
$query
.=
' AND generated='
.
$this
->
conn
->
quote
(
'N'
,
'text'
);
$query
=
'SELECT index_name name FROM user_indexes'
.
' WHERE table_name = '
.
$table
.
' OR table_name = '
.
strtoupper
(
$table
)
.
' AND generated = '
.
$this
->
conn
->
quote
(
'N'
,
'text'
);
$indexes
=
$this
->
conn
->
fetchColumn
(
$query
);
return
array_map
(
array
(
$this
->
conn
,
'fixIndexName'
),
$indexes
);
...
...
@@ -183,14 +187,18 @@ class Doctrine_Import_Oracle extends Doctrine_Import
*/
public
function
listUsers
()
{
/**
if ($this->conn->options['emulate_database'] && $this->conn->options['database_name_prefix']) {
$query = 'SELECT SUBSTR(username, ';
$query.= (strlen($this->conn->options['database_name_prefix'])+1);
$query.= ") FROM sys.dba_users WHERE username NOT LIKE '";
$query.= $this->conn->options['database_name_prefix']."%'";
} else {
$query
=
'SELECT username FROM sys.dba_users'
;
}
*/
$query
=
'SELECT username FROM sys.dba_users'
;
//}
return
$this
->
conn
->
fetchColumn
(
$query
);
}
/**
...
...
tests/DriverTestCase.php
View file @
b7ab7229
...
...
@@ -73,7 +73,7 @@ class AdapterMock implements Doctrine_Adapter_Interface {
if
(
$fail
)
{
$this
->
lastInsertIdFail
=
true
;
}
else
{
$this
->
lastInsertIdFail
=
false
;
$this
->
lastInsertIdFail
=
false
;
}
}
public
function
lastInsertId
()
...
...
@@ -125,7 +125,7 @@ class AdapterStatementMock {
$this
->
mock
->
addQuery
(
$this
->
query
);
return
true
;
}
public
function
fetchColumn
(
$colnum
)
{
public
function
fetchColumn
(
$colnum
=
0
)
{
return
0
;
}
}
...
...
tests/Import/OracleTestCase.php
View file @
b7ab7229
...
...
@@ -30,5 +30,77 @@
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Import_Oracle_TestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_Import_Oracle_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testListSequencesExecutesSql
()
{
$this
->
conn
->
setAttribute
(
Doctrine
::
ATTR_EMULATE_DATABASE
,
true
);
$this
->
import
->
listSequences
(
'table'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
"SELECT sequence_name FROM sys.user_sequences"
);
}
public
function
testListTableColumnsExecutesSql
()
{
$this
->
import
->
listTableColumns
(
'table'
);
$q
=
"SELECT column_name, data_type, data_length, nullable, data_default from all_tab_columns"
.
" WHERE table_name = 'TABLE' ORDER BY column_name"
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
public
function
testListTableIndexesExecutesSql
()
{
$this
->
import
->
listTableIndexes
(
'table'
);
$q
=
'SELECT index_name name FROM user_indexes'
.
" WHERE table_name = 'table' OR table_name = 'TABLE'"
.
" AND generated = 'N'"
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
public
function
testListTablesExecutesSql
()
{
$this
->
import
->
listTables
();
$q
=
'SELECT table_name FROM sys.user_tables'
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
public
function
testListDatabasesExecutesSql
()
{
$this
->
import
->
listDatabases
();
$q
=
'SELECT username FROM sys.dba_users'
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
public
function
testListUsersExecutesSql
()
{
$this
->
import
->
listUsers
();
$q
=
'SELECT username FROM sys.dba_users'
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
public
function
testListViewsExecutesSql
()
{
$this
->
import
->
listViews
();
$q
=
'SELECT view_name FROM sys.user_views'
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
public
function
testListFunctionsExecutesSql
()
{
$this
->
import
->
listFunctions
();
$q
=
"SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'"
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
public
function
testListTableConstraintsExecutesSql
()
{
$this
->
import
->
listTableConstraints
(
'table'
);
$q
=
"SELECT index_name name FROM user_constraints"
.
" WHERE table_name = 'table' OR table_name = 'TABLE'"
;
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
$q
);
}
}
tests/Import/PgsqlTestCase.php
View file @
b7ab7229
...
...
@@ -151,7 +151,8 @@ class Doctrine_Import_Pgsql_TestCase extends Doctrine_UnitTestCase
public
function
testListTableConstraintsExecutesSql
()
{
$this
->
import
->
listTableConstraints
(
'table'
);
$q
=
"SELECT
relname
FROM
...
...
tests/TreeStructureTestCase.php
View file @
b7ab7229
...
...
@@ -88,5 +88,15 @@ class Doctrine_TreeStructure_TestCase extends Doctrine_UnitTestCase
$this
->
assertTrue
(
count
(
$o4
->
Children
)
==
0
);
$this
->
assertFalse
(
isset
(
$o4
->
Parent
));
}
}
public
function
testTreeStructureFetchingWorksWithDql
()
{
$q
=
new
Doctrine_Query
();
$q
->
select
(
'l.*, c.*'
)
->
from
(
'TreeLeaf l, l.Children c'
)
->
where
(
'l.parent_id IS NULL'
)
->
groupby
(
'l.id, c.id'
);
$coll
=
$q
->
execute
();
}
}
tests/run.php
View file @
b7ab7229
...
...
@@ -60,10 +60,16 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
$test
->
addTestCase
(
new
Doctrine_Import_Firebird_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Informix_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Mysql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Mssql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Pgsql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Oracle_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Sqlite_TestCase
());
// DATABASE ABSTRACTION tests
/**
// Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
...
...
@@ -117,13 +123,7 @@ $test->addTestCase(new Doctrine_Export_Sqlite_TestCase());
// Import module (not yet fully tested)
//$test->addTestCase(new Doctrine_Import_TestCase());
$test
->
addTestCase
(
new
Doctrine_Import_Firebird_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Informix_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Mysql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Mssql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Pgsql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Oracle_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Sqlite_TestCase
());
// Expression module (not yet fully tested)
$test->addTestCase(new Doctrine_Expression_TestCase());
...
...
@@ -155,7 +155,6 @@ $test->addTestCase(new Doctrine_Relation_Access_TestCase());
$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
$test->addTestCase(new Doctrine_Relation_OneToOne_TestCase());
$test
->
addTestCase
(
new
Doctrine_TreeStructure_TestCase
());
// Datatypes
...
...
@@ -215,6 +214,9 @@ $test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
$test->addTestCase(new Doctrine_Query_Join_TestCase());
$test->addTestCase(new Doctrine_ColumnAlias_TestCase());
*/
$test
->
addTestCase
(
new
Doctrine_TreeStructure_TestCase
());
// Cache tests
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
...
...
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