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
0aac52ef
Commit
0aac52ef
authored
Jan 04, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
83d89b76
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
28 deletions
+47
-28
Export.php
lib/Doctrine/Export.php
+7
-5
Hook.php
lib/Doctrine/Hook.php
+23
-6
Complex.php
lib/Doctrine/Hook/Parser/Complex.php
+4
-10
WordLike.php
lib/Doctrine/Hook/WordLike.php
+13
-5
Query.php
lib/Doctrine/Query.php
+0
-2
No files found.
lib/Doctrine/Export.php
View file @
0aac52ef
...
...
@@ -133,9 +133,11 @@ class Doctrine_Export extends Doctrine_Connection_Module
*
* @return void
*/
public
function
createTable
(
$name
,
array
$fields
,
array
$options
=
array
())
{
if
(
!
$name
)
public
function
createTable
(
$name
,
array
$fields
,
array
$options
=
array
())
{
if
(
!
$name
)
{
throw
new
Doctrine_Export_Exception
(
'no valid table name specified'
);
}
if
(
empty
(
$fields
))
{
throw
new
Doctrine_Export_Exception
(
'no fields specified for table '
.
$name
);
...
...
@@ -148,7 +150,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
$query
=
'CREATE TABLE '
.
$name
.
' ('
.
$queryFields
.
')'
;
print
$query
.
"<br \>"
;
return
$this
->
conn
->
exec
(
$query
);
}
/**
...
...
@@ -653,7 +655,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
$this
->
createTable
(
$table
->
getTableName
(),
$columns
);
}
catch
(
Doctrine_Connection_Exception
$e
)
{
$reporter
->
add
(
E_ERROR
,
$e
->
get
Cod
e
());
$reporter
->
add
(
E_ERROR
,
$e
->
get
Messag
e
());
}
return
$reporter
;
...
...
lib/Doctrine/Hook.php
View file @
0aac52ef
...
...
@@ -54,17 +54,22 @@ class Doctrine_Hook
*/
protected
$params
=
array
();
/**
* @var array $fieldParsers
* @var array $fieldParsers custom field parsers array
* keys as field names in the format componentAlias.FieldName
* values as parser names / objects
*/
protected
$fieldParsers
=
array
();
/**
* @var array $typeParsers
* @var array $typeParsers type parsers array
* keys as type names and values as parser names / objects
*/
protected
$typeParsers
=
array
(
'char'
=>
'Doctrine_Hook_WordLike'
,
'string'
=>
'Doctrine_Hook_WordLike'
,
'integer'
=>
'Doctrine_Hook_Integer'
,
'time'
=>
'Doctrine_Hook_Time'
,
'date'
=>
'Doctrine_Hook_Date'
,
);
/**
...
...
@@ -88,13 +93,25 @@ class Doctrine_Hook
{
return
$this
->
query
;
}
public
function
leftJoin
(
$dql
)
/**
* setTypeParser
*
* @param string $type type name
* @param string|object $parser parser name or custom parser object
*/
public
function
setTypeParser
(
$type
,
$parser
)
{
$this
->
typeParsers
[
$type
]
=
$parser
;
}
public
function
innerJoin
(
$dql
)
/**
* setFieldParser
*
* @param string $field field name
* @param string|object $parser parser name or custom parser object
*/
public
function
setFieldParser
(
$field
,
$parser
)
{
$this
->
fieldParsers
[
$field
]
=
$parser
;
}
/**
* hookWhere
...
...
lib/Doctrine/Hook/Parser/Complex.php
View file @
0aac52ef
...
...
@@ -58,35 +58,29 @@ abstract class Doctrine_Hook_Parser_Complex extends Doctrine_Hook_Parser
*/
public
function
parseClause
(
$alias
,
$field
,
$value
)
{
$parts
=
Doctrine_Query
::
bracketExplode
(
$value
,
' AND '
,
'('
,
')
'
);
$parts
=
Doctrine_Query
::
quoteExplode
(
$value
,
' AND
'
);
if
(
count
(
$parts
)
>
1
)
{
$ret
=
array
();
foreach
(
$parts
as
$part
)
{
$part
=
Doctrine_Query
::
bracketTrim
(
$part
,
'('
,
')'
);
$ret
[]
=
$this
->
parseSingle
(
$alias
,
$field
,
$part
);
}
$r
=
implode
(
' AND '
,
$ret
);
}
else
{
$parts
=
Doctrine_Query
::
bracketExplode
(
$value
,
' OR '
,
'('
,
')
'
);
$parts
=
Doctrine_Query
::
quoteExplode
(
$value
,
' OR
'
);
if
(
count
(
$parts
)
>
1
)
{
$ret
=
array
();
foreach
(
$parts
as
$part
)
{
$part
=
Doctrine_Query
::
bracketTrim
(
$part
,
'('
,
')'
);
$ret
[]
=
$this
->
parseClause
(
$alias
,
$field
,
$part
);
}
$r
=
implode
(
' OR '
,
$ret
);
}
else
{
if
(
substr
(
$parts
[
0
],
0
,
1
)
==
'('
&&
substr
(
$parts
[
0
],
-
1
)
==
')'
)
{
return
$this
->
parseClause
(
substr
(
$parts
[
0
],
1
,
-
1
));
}
else
{
$ret
=
$this
->
parseSingle
(
$alias
,
$field
,
$parts
[
0
]);
return
$ret
;
}
}
}
return
'('
.
$r
.
')'
;
}
/**
...
...
lib/Doctrine/Hook/WordLike.php
View file @
0aac52ef
...
...
@@ -46,13 +46,21 @@ class Doctrine_Hook_WordLike extends Doctrine_Hook_Parser_Complex
*/
public
function
parseSingle
(
$alias
,
$field
,
$value
)
{
if
(
strpos
(
$value
,
"'"
)
!==
false
)
{
$value
=
Doctrine_Query
::
bracketTrim
(
$value
,
"'"
,
"'"
);
$a
[]
=
$alias
.
'.'
.
$field
.
' LIKE ?'
;
$this
->
params
[]
=
$value
.
'%'
;
}
else
{
$e2
=
explode
(
' '
,
$value
);
foreach
(
$e2
as
$v
)
{
$v
=
trim
(
$v
);
$a
[]
=
$alias
.
'.'
.
$field
.
' LIKE ?'
;
$a
[]
=
$alias
.
'.'
.
$field
.
' LIKE ?'
;
$this
->
params
[]
=
$v
.
'%'
;
}
}
return
implode
(
' OR '
,
$a
);
}
}
lib/Doctrine/Query.php
View file @
0aac52ef
...
...
@@ -1023,8 +1023,6 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
* parameters:
* $str = email LIKE 'John@example.com'
* $d = ' AND '
* $e1 = '('
* $e2 = ')'
*
* would return an array:
* array("email", "LIKE", "'John@example.com'")
...
...
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