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
cec372df
Commit
cec372df
authored
Sep 25, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doctrine_DataDict_Sqlite driver
parent
70ebe0d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
101 deletions
+139
-101
Connection.php
Doctrine/Connection.php
+9
-1
DataDict.php
Doctrine/DataDict.php
+1
-1
Sqlite.php
Doctrine/DataDict/Sqlite.php
+24
-4
Column.php
Doctrine/Schema/Column.php
+36
-95
DB.php
draft/DB.php
+7
-0
DataDictSqliteTestCase.php
tests/DataDictSqliteTestCase.php
+62
-0
No files found.
Doctrine/Connection.php
View file @
cec372df
...
...
@@ -94,11 +94,19 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* returns the database handler of which this connection uses
*
* @return
object PDO
the database handler
* @return
PDO
the database handler
*/
public
function
getDBH
()
{
return
$this
->
dbh
;
}
/**
* returns a datadict object
*
* @return Doctrine_DataDict
*/
public
function
getDataDict
()
{
}
/**
* returns the regular expression operator
* (implemented by the connection drivers)
...
...
Doctrine/DataDict.php
View file @
cec372df
...
...
@@ -28,7 +28,7 @@
*/
class
Doctrine_DataDict
{
pr
ivate
$dbh
;
pr
otected
$dbh
;
public
function
__construct
(
PDO
$dbh
)
{
$file
=
Doctrine
::
getPath
()
.
DIRECTORY_SEPARATOR
.
"Doctrine"
.
DIRECTORY_SEPARATOR
.
"adodb-hack"
.
DIRECTORY_SEPARATOR
.
"adodb.inc.php"
;
...
...
Doctrine/DataDict/Sqlite.php
View file @
cec372df
...
...
@@ -27,7 +27,7 @@
* @version $Id$
*/
class
Doctrine_DataDict_Sqlite
{
class
Doctrine_DataDict_Sqlite
extends
Doctrine_DataDict
{
/**
* lists all databases
*
...
...
@@ -78,7 +78,23 @@ class Doctrine_DataDict_Sqlite {
* @return array
*/
public
function
listTableColumns
(
$table
)
{
$sql
=
"PRAGMA table_info(
$table
)"
;
$result
=
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$description
=
array
();
$columns
=
array
();
foreach
(
$result
as
$key
=>
$val
)
{
$description
=
array
(
'name'
=>
$val
[
'name'
],
'type'
=>
$val
[
'type'
],
'notnull'
=>
(
bool
)
$val
[
'notnull'
],
'default'
=>
$val
[
'dflt_value'
],
'primary'
=>
(
bool
)
$val
[
'pk'
],
);
$columns
[
$val
[
'name'
]]
=
new
Doctrine_Schema_Column
(
$description
);
}
return
$columns
;
}
/**
* lists table constraints
...
...
@@ -90,13 +106,17 @@ class Doctrine_DataDict_Sqlite {
}
/**
* lists table
constraint
s
* lists tables
*
* @param string|null $database
* @return array
*/
public
function
listTables
(
$database
=
null
)
{
$sql
=
"SELECT name FROM sqlite_master WHERE type='table' "
.
"UNION ALL SELECT name FROM sqlite_temp_master "
.
"WHERE type='table' ORDER BY name"
;
return
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
/**
* lists table triggers
...
...
Doctrine/Schema/Column.php
View file @
cec372df
...
...
@@ -33,102 +33,43 @@
* class Doctrine_Schema_Column
* Holds information on a database table field
*/
class
Doctrine_Schema_Column
extends
Doctrine_Schema_Object
implements
IteratorAggregate
{
/** Aggregations: */
/** Compositions: */
var
$m_Vector
=
array
();
/*** Attributes: ***/
/**
* Column name
* @access public
*/
public
$name
;
/**
* Column type e.g. varchar, char, int etc.
* @access public
*/
public
$type
;
/**
* Field max length
* @access public
*/
public
$length
;
/**
* Is an autoincrement column
* @access public
*/
public
$autoincrement
;
/**
* Default field value
* @access public
*/
public
$default
;
/**
* Is not null
* @access public
*/
public
$notNull
;
class
Doctrine_Schema_Column
extends
Doctrine_Schema_Object
implements
IteratorAggregate
{
/**
*
Column comment
* @
access public
*
column definitions
* @
var array $definition
*/
public
$description
;
/**
* Column level check constraint
* @access public
*/
public
$check
;
/**
* Character encoding e.g. ISO-8859-1 or UTF-8 etc.
* @access public
*/
public
$charset
;
/**
*
* @return
* @access public
*/
public
function
__toString
(
)
{
}
// end of member function __toString
/**
*
* @return
* @access public
*/
public
function
__clone
(
)
{
}
// end of member function __clone
/**
*
* @return bool
* @access public
*/
public
function
isValid
(
)
{
}
// end of member function isValid
private
$definition
=
array
(
'name'
=>
''
,
'type'
=>
''
,
'unique'
=>
false
,
'primary'
=>
false
,
'notnull'
=>
false
,
'default'
=>
null
,
);
public
function
__construct
(
array
$definition
)
{
foreach
(
$this
->
definition
as
$key
=>
$val
)
{
if
(
isset
(
$definition
[
$key
]))
$this
->
definition
[
$key
]
=
$definition
[
$key
];
}
}
public
function
getName
()
{
return
$this
->
definition
[
'name'
];
}
public
function
getType
()
{
return
$this
->
definition
[
'type'
];
}
public
function
isUnique
()
{
return
$this
->
definition
[
'unique'
];
}
public
function
isPrimaryKey
()
{
return
$this
->
definition
[
'primary'
];
}
public
function
defaultValue
()
{
return
$this
->
definition
[
'default'
];
}
public
function
isNotNull
()
{
return
$this
->
definition
[
'notnull'
];
}
}
// end of Doctrine_Schema_Column
draft/DB.php
View file @
cec372df
...
...
@@ -360,6 +360,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
return
$rows
;
}
/**
* fetchAll
*/
public
function
fetchAssoc
(
$statement
,
$params
=
array
())
{
if
(
!
$params
)
$this
->
query
(
$statement
);
}
/**
* lastInsertId
*
...
...
tests/DataDictSqliteTestCase.php
0 → 100644
View file @
cec372df
<?php
class
Doctrine_DataDict_Sqlite_TestCase
extends
Doctrine_UnitTestCase
{
private
$dict
;
private
$columns
;
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
dbh
->
query
(
"CREATE TABLE test (col_null NULL,
col_int INTEGER NOT NULL,
col_real REAL,
col_text TEXT DEFAULT 'default' NOT NULL,
col_blob BLOB)"
);
$this
->
dict
=
new
Doctrine_DataDict_Sqlite
(
$this
->
dbh
);
$this
->
columns
=
$this
->
dict
->
listTableColumns
(
'test'
);
}
public
function
testListTables
()
{
$result
=
$this
->
dict
->
listTables
();
}
public
function
testIntegerType
()
{
$this
->
assertEqual
(
$this
->
columns
[
'col_int'
]
->
isUnique
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_int'
]
->
isNotNull
(),
true
);
$this
->
assertEqual
(
$this
->
columns
[
'col_int'
]
->
defaultValue
(),
null
);
$this
->
assertEqual
(
$this
->
columns
[
'col_int'
]
->
isPrimaryKey
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_int'
]
->
getType
(),
'INTEGER'
);
$this
->
assertEqual
(
$this
->
columns
[
'col_int'
]
->
getName
(),
'col_int'
);
}
public
function
testNullType
()
{
$this
->
assertEqual
(
$this
->
columns
[
'col_null'
]
->
isUnique
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_null'
]
->
isNotNull
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_null'
]
->
defaultValue
(),
null
);
$this
->
assertEqual
(
$this
->
columns
[
'col_null'
]
->
isPrimaryKey
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_null'
]
->
getType
(),
'numeric'
);
$this
->
assertEqual
(
$this
->
columns
[
'col_null'
]
->
getName
(),
'col_null'
);
}
public
function
testTextType
()
{
$this
->
assertEqual
(
$this
->
columns
[
'col_text'
]
->
isUnique
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_text'
]
->
isNotNull
(),
true
);
$this
->
assertEqual
(
$this
->
columns
[
'col_text'
]
->
defaultValue
(),
'default'
);
$this
->
assertEqual
(
$this
->
columns
[
'col_text'
]
->
isPrimaryKey
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_text'
]
->
getType
(),
'TEXT'
);
$this
->
assertEqual
(
$this
->
columns
[
'col_text'
]
->
getName
(),
'col_text'
);
}
public
function
testBlobType
()
{
$this
->
assertEqual
(
$this
->
columns
[
'col_blob'
]
->
isUnique
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_blob'
]
->
isNotNull
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_blob'
]
->
defaultValue
(),
null
);
$this
->
assertEqual
(
$this
->
columns
[
'col_blob'
]
->
isPrimaryKey
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_blob'
]
->
getType
(),
'BLOB'
);
$this
->
assertEqual
(
$this
->
columns
[
'col_blob'
]
->
getName
(),
'col_blob'
);
}
public
function
testRealType
()
{
$this
->
assertEqual
(
$this
->
columns
[
'col_real'
]
->
isUnique
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_real'
]
->
isNotNull
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_real'
]
->
defaultValue
(),
null
);
$this
->
assertEqual
(
$this
->
columns
[
'col_real'
]
->
isPrimaryKey
(),
false
);
$this
->
assertEqual
(
$this
->
columns
[
'col_real'
]
->
getType
(),
'REAL'
);
$this
->
assertEqual
(
$this
->
columns
[
'col_real'
]
->
getName
(),
'col_real'
);
}
}
?>
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