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
cb20dfaf
Commit
cb20dfaf
authored
Dec 02, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated datadict drivers
parent
cbf0120f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
28 additions
and
143 deletions
+28
-143
Doctrine.php
lib/Doctrine.php
+12
-0
DataDict.php
lib/Doctrine/DataDict.php
+3
-132
Firebird.php
lib/Doctrine/DataDict/Firebird.php
+1
-1
Mssql.php
lib/Doctrine/DataDict/Mssql.php
+1
-1
Mysql.php
lib/Doctrine/DataDict/Mysql.php
+1
-1
Oracle.php
lib/Doctrine/DataDict/Oracle.php
+1
-1
Pgsql.php
lib/Doctrine/DataDict/Pgsql.php
+1
-1
Sqlite.php
lib/Doctrine/DataDict/Sqlite.php
+1
-1
Export.php
lib/Doctrine/Export.php
+4
-3
Record.php
lib/Doctrine/Record.php
+1
-1
Table.php
lib/Doctrine/Table.php
+1
-1
Transaction.php
lib/Doctrine/Transaction.php
+1
-0
No files found.
lib/Doctrine.php
View file @
cb20dfaf
...
...
@@ -374,5 +374,17 @@ final class Doctrine {
public
static
function
classify
(
$tablename
)
{
return
preg_replace
(
'~(_?)(_)([\w])~e'
,
'"$1".strtoupper("$3")'
,
ucfirst
(
$tablename
));
}
/**
* checks for valid class name (uses camel case and underscores)
*
* @param string $classname
* @return boolean
*/
public
static
function
isValidClassname
(
$classname
)
{
if
(
preg_match
(
'~(^[a-z])|(_[a-z])|([\W])|(_{2})~'
,
$classname
))
throw
new
Doctrine_Exception
(
"Class name is not valid. Use camel case and underscores (i.e My_PerfectClass)."
);
return
true
;
}
}
?>
lib/Doctrine/DataDict.php
View file @
cb20dfaf
...
...
@@ -27,139 +27,10 @@
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/
class
Doctrine_DataDict
{
class
Doctrine_DataDict
extends
Doctrine_Connection_Module
{
protected
$dbh
;
public
function
__construct
(
$dbh
=
null
)
{
$file
=
Doctrine
::
getPath
()
.
DIRECTORY_SEPARATOR
.
"Doctrine"
.
DIRECTORY_SEPARATOR
.
"adodb-hack"
.
DIRECTORY_SEPARATOR
.
"adodb.inc.php"
;
if
(
!
file_exists
(
$file
))
throw
new
Doctrine_Exception
(
"Couldn't include datadict. File
$file
does not exist"
);
require_once
(
$file
);
$this
->
dbh
=
$dbh
;
if
(
$dbh
)
$this
->
dict
=
NewDataDictionary
(
$dbh
);
}
/**
* metaColumns
*
* @param Doctrine_Table $table
* @return array
*/
public
function
metaColumns
(
Doctrine_Table
$table
)
{
return
$this
->
dict
->
metaColumns
(
$table
->
getTableName
());
}
/**
* createTable
*
* @param string $tablename
* @param array $columns
* @return boolean
*/
public
function
createTable
(
$tablename
,
array
$columns
)
{
foreach
(
$columns
as
$name
=>
$args
)
{
if
(
!
is_array
(
$args
[
2
]))
$args
[
2
]
=
array
();
unset
(
$args
[
2
][
'default'
]);
$constraints
=
array_keys
(
$args
[
2
]);
$r
[]
=
$name
.
" "
.
$this
->
getADOType
(
$args
[
0
],
$args
[
1
])
.
" "
.
implode
(
' '
,
$constraints
);
}
$r
=
implode
(
", "
,
$r
);
$a
=
$this
->
dict
->
createTableSQL
(
$tablename
,
$r
);
$return
=
true
;
foreach
(
$a
as
$sql
)
{
try
{
$this
->
dbh
->
query
(
$sql
);
}
catch
(
Exception
$e
)
{
$return
=
$e
;
}
}
return
$return
;
}
/**
* converts doctrine type to adodb type
*
* @param string $type column type
* @param integer $length column length
*/
public
function
getADOType
(
$type
,
$length
)
{
switch
(
$type
)
:
case
"array"
:
case
"object"
:
case
"string"
:
case
"gzip"
:
if
(
$length
<=
255
)
return
"C(
$length
)"
;
elseif
(
$length
<=
4000
)
return
"X"
;
else
return
"X2"
;
break
;
case
"mbstring"
:
if
(
$length
<=
255
)
return
"C2(
$length
)"
;
return
"X2"
;
case
"clob"
:
return
"XL"
;
break
;
case
"blob"
:
return
"B"
;
break
;
case
"date"
:
return
"D"
;
break
;
case
"float"
:
case
"double"
:
return
"F"
;
break
;
case
"timestamp"
:
return
"T"
;
break
;
case
"boolean"
:
return
"L"
;
break
;
case
"enum"
:
case
"integer"
:
if
(
empty
(
$length
))
return
"I8"
;
elseif
(
$length
<
4
)
return
"I1"
;
elseif
(
$length
<
6
)
return
"I2"
;
elseif
(
$length
<
10
)
return
"I4"
;
else
return
"I8"
;
break
;
default
:
throw
new
Doctrine_Exception
(
"Unknown column type
$type
"
);
endswitch
;
}
/**
* checks for valid class name (uses camel case and underscores)
*
* @param string $classname
* @return boolean
*/
public
static
function
isValidClassname
(
$classname
)
{
if
(
preg_match
(
'~(^[a-z])|(_[a-z])|([\W])|(_{2})~'
,
$classname
))
throw
new
Doctrine_Exception
(
"Class name is not valid. Use camel case and underscores (i.e My_PerfectClass)."
);
return
true
;
}
}
lib/Doctrine/DataDict/Firebird.php
View file @
cb20dfaf
...
...
@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class
Doctrine_DataDict_Firebird
extends
Doctrine_
Connection_Module
{
class
Doctrine_DataDict_Firebird
extends
Doctrine_
DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
...
...
lib/Doctrine/DataDict/Mssql.php
View file @
cb20dfaf
...
...
@@ -30,7 +30,7 @@
* @link www.phpdoctrine.com
* @since 1.0
*/
class
Doctrine_DataDict_Mssql
extends
Doctrine_
Connection_Module
{
class
Doctrine_DataDict_Mssql
extends
Doctrine_
DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
...
...
lib/Doctrine/DataDict/Mysql.php
View file @
cb20dfaf
...
...
@@ -29,7 +29,7 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class
Doctrine_DataDict_Mysql
extends
Doctrine_
Connection_Module
{
class
Doctrine_DataDict_Mysql
extends
Doctrine_
DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
...
...
lib/Doctrine/DataDict/Oracle.php
View file @
cb20dfaf
...
...
@@ -27,7 +27,7 @@
* @link www.phpdoctrine.com
* @since 1.0
*/
class
Doctrine_DataDict_Oracle
extends
Doctrine_
Connection_Module
{
class
Doctrine_DataDict_Oracle
extends
Doctrine_
DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
...
...
lib/Doctrine/DataDict/Pgsql.php
View file @
cb20dfaf
...
...
@@ -29,7 +29,7 @@
* @link www.phpdoctrine.com
* @since 1.0
*/
class
Doctrine_DataDict_Pgsql
extends
Doctrine_
Connection_Module
{
class
Doctrine_DataDict_Pgsql
extends
Doctrine_
DataDict
{
/**
* @param array $reservedKeyWords an array of reserved keywords by pgsql
*/
...
...
lib/Doctrine/DataDict/Sqlite.php
View file @
cb20dfaf
...
...
@@ -29,7 +29,7 @@ Doctrine::autoload('Doctrine_DataDict');
* @link www.phpdoctrine.com
* @since 1.0
*/
class
Doctrine_DataDict_Sqlite
extends
Doctrine_
Connection_Module
{
class
Doctrine_DataDict_Sqlite
extends
Doctrine_
DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
...
...
lib/Doctrine/Export.php
View file @
cb20dfaf
...
...
@@ -24,6 +24,7 @@ Doctrine::autoload('Doctrine_Connection_Module');
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
...
...
@@ -147,11 +148,11 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* create sequence
* (this method is implemented by the drivers)
*
* @param string $seq
_name
name of the sequence to be created
* @param string $start start value of the sequence; default is 1
* @param string $seq
Name
name of the sequence to be created
* @param string $start
start value of the sequence; default is 1
* @return void
*/
public
function
createSequence
(
$seq
_n
ame
,
$start
=
1
)
{
public
function
createSequence
(
$seq
N
ame
,
$start
=
1
)
{
throw
new
Doctrine_Export_Exception
(
'Create sequence not supported by this driver.'
);
}
...
...
lib/Doctrine/Record.php
View file @
cb20dfaf
...
...
@@ -134,7 +134,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
__construct
(
$table
=
null
,
$isNewEntry
=
false
)
{
if
(
isset
(
$table
)
&&
$table
instanceof
Doctrine_Table
)
{
$this
->
_table
=
$table
;
$exists
=
!
$isNewEntry
;
$exists
=
(
!
$isNewEntry
)
;
}
else
{
$this
->
_table
=
Doctrine_Manager
::
getInstance
()
->
getCurrentConnection
()
->
getTable
(
get_class
(
$this
));
$exists
=
false
;
...
...
lib/Doctrine/Table.php
View file @
cb20dfaf
...
...
@@ -241,7 +241,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
endswitch
;
if
(
$this
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
))
{
if
(
Doctrine
_DataDict
::
isValidClassname
(
$class
->
getName
()))
{
if
(
Doctrine
::
isValidClassname
(
$class
->
getName
()))
{
//$dict = new Doctrine_DataDict($this->getConnection()->getDBH());
try
{
$columns
=
array
();
...
...
lib/Doctrine/Transaction.php
View file @
cb20dfaf
...
...
@@ -22,6 +22,7 @@ Doctrine::autoload('Doctrine_Connection_Module');
/**
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @category Object Relational Mapping
...
...
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