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
0c94b003
Commit
0c94b003
authored
Sep 29, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some docs for the upcoming new Doctrine_DB
parent
487e07ae
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
9 deletions
+126
-9
Basic Components - Connection - Querying the database.php
...Basic Components - Connection - Querying the database.php
+6
-2
Basic Components - DB - Chaining listeners.php
manual/codes/Basic Components - DB - Chaining listeners.php
+34
-0
Basic Components - DB - Connecting to a database.php
...odes/Basic Components - DB - Connecting to a database.php
+11
-0
Basic Components - DB - Using event listeners.php
...l/codes/Basic Components - DB - Using event listeners.php
+36
-0
Basic Components - Record - Checking existence.php
.../codes/Basic Components - Record - Checking existence.php
+10
-0
Basic Components - Record - Getting record state.php
...odes/Basic Components - Record - Getting record state.php
+5
-5
Basic Components - Connection - Querying the database.php
...Basic Components - Connection - Querying the database.php
+1
-0
Basic Components - DB - Connecting to a database.php
...docs/Basic Components - DB - Connecting to a database.php
+10
-0
Basic Components - DB - Introduction.php
manual/docs/Basic Components - DB - Introduction.php
+10
-0
documentation.php
manual/documentation.php
+3
-2
No files found.
manual/codes/Basic Components - Connection - Querying the database.php
View file @
0c94b003
...
@@ -2,9 +2,13 @@
...
@@ -2,9 +2,13 @@
// select all users
// select all users
$conn
->
query
(
"FROM User"
);
$
users
=
$
conn
->
query
(
"FROM User"
);
// select all users where user email is jackdaniels@drinkmore.info
// select all users where user email is jackdaniels@drinkmore.info
$conn
->
query
(
"FROM User WHERE User.Email.address = 'jackdaniels@drinkmore.info'"
);
$users
=
$conn
->
query
(
"FROM User WHERE User.Email.address = 'jackdaniels@drinkmore.info'"
);
// using prepared statements
$users
=
$conn
->
query
(
"FROM User WHERE User.name = ?"
,
array
(
'Jack'
));
?>
?>
manual/codes/Basic Components - DB - Chaining listeners.php
0 → 100644
View file @
0c94b003
<?php
// using PDO dsn for connecting sqlite memory table
$dbh
=
Doctrine_DB
::
getConnection
(
'sqlite::memory:'
);
class
Counter
extends
Doctrine_DB_EventListener
{
private
$queries
=
0
;
public
function
onQuery
(
Doctrine_DB
$dbh
,
$query
,
$params
)
{
$this
->
queries
++
;
}
public
function
count
()
{
return
count
(
$this
->
queries
);
}
}
class
OutputLogger
extends
Doctrine_Overloadable
{
public
function
__call
(
$m
,
$a
)
{
print
$m
.
" called!"
;
}
}
$counter
=
new
Counter
();
$dbh
->
addListener
(
$counter
);
$dbh
->
addListener
(
new
OutputLogger
());
$dbh
->
query
(
"SELECT * FROM foo"
);
// prints:
// onPreQuery called!
// onQuery called!
print
$counter
->
count
();
// 1
?>
manual/codes/Basic Components - DB - Connecting to a database.php
0 → 100644
View file @
0c94b003
<?php
// using PDO dsn for connecting sqlite memory table
$dbh
=
Doctrine_DB
::
getConnection
(
'sqlite::memory:'
);
// using PEAR like dsn for connecting mysql database
$dsn
=
'mysql://root:password@localhost/test'
;
$dbh
=
Doctrine_DB
::
getConnection
(
$dsn
);
?>
manual/codes/Basic Components - DB - Using event listeners.php
0 → 100644
View file @
0c94b003
<?php
// using PDO dsn for connecting sqlite memory table
$dbh
=
Doctrine_DB
::
getConnection
(
'sqlite::memory:'
);
class
MyLogger
extends
Doctrine_DB_EventListener
{
public
function
onPreQuery
(
Doctrine_DB
$dbh
,
$query
,
$params
)
{
print
"database is going to be queried!"
;
}
public
function
onQuery
(
Doctrine_DB
$dbh
,
$query
,
$params
)
{
print
"executed:
$query
"
;
}
}
$dbh
->
setListener
(
new
MyLogger
());
$dbh
->
query
(
"SELECT * FROM foo"
);
// prints:
// database is going to be queried
// executed: SELECT * FROM foo
class
MyLogger2
extends
Doctrine_Overloadable
{
public
function
__call
(
$m
,
$a
)
{
print
$m
.
" called!"
;
}
}
$dbh
->
setListener
(
new
MyLogger2
());
$dbh
->
exec
(
"DELETE FROM foo"
);
// prints:
// onPreExec called!
// onExec called!
?>
manual/codes/Basic Components - Record - Checking existence.php
0 → 100644
View file @
0c94b003
<?php
$record
=
new
User
();
$record
->
exists
();
// false
$record
->
name
=
'someone'
;
$record
->
save
();
$record
->
exists
();
// true
?>
manual/codes/Basic Components - Record - Getting record state.php
View file @
0c94b003
...
@@ -3,27 +3,27 @@ $state = $record->getState();
...
@@ -3,27 +3,27 @@ $state = $record->getState();
switch
(
$state
)
:
switch
(
$state
)
:
case
Doctrine_Record
::
STATE_PROXY
:
case
Doctrine_Record
::
STATE_PROXY
:
//
data access object
is in proxy state,
//
record
is in proxy state,
// meaning its persistent but not all of its properties are
// meaning its persistent but not all of its properties are
// loaded from the database
// loaded from the database
break
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
case
Doctrine_Record
::
STATE_TCLEAN
:
//
data access object
is transient clean,
//
record
is transient clean,
// meaning its transient and
// meaning its transient and
// none of its properties are changed
// none of its properties are changed
break
;
break
;
case
Doctrine_Record
::
STATE_TDIRTY
:
case
Doctrine_Record
::
STATE_TDIRTY
:
//
data access object is transient dirty,
//
record is transient dirty,
// meaning its transient and
// meaning its transient and
// some of its properties are changed
// some of its properties are changed
break
;
break
;
case
Doctrine_Record
::
STATE_DIRTY
:
case
Doctrine_Record
::
STATE_DIRTY
:
//
data access object
is dirty,
//
record
is dirty,
// meaning its persistent and
// meaning its persistent and
// some of its properties are changed
// some of its properties are changed
break
;
break
;
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_CLEAN
:
//
data access object is clean,
//
record is clean,
// meaning its persistent and
// meaning its persistent and
// none of its properties are changed
// none of its properties are changed
break
;
break
;
...
...
manual/docs/Basic Components - Connection - Querying the database.php
View file @
0c94b003
Doctrine_Connection
::
query
()
is
a
simple
method
for
efficient
object
retrieval
.
It
takes
one
parameter
(
DQL
query
)
and
optionally
prepared
statement
params
.
manual/docs/Basic Components - DB - Connecting to a database.php
0 → 100644
View file @
0c94b003
<?php
// using PDO dsn for connecting sqlite memory table
//$dbh = Doctrine_DB::getConnection('sqlite::memory:');
// using PEAR like dsn for connecting mysql database
//$dbh = Doctrine_DB::getConnection('mysql://root:password@localhost/test');
?>
manual/docs/Basic Components - DB - Introduction.php
0 → 100644
View file @
0c94b003
Doctrine_DB
is
a
wrapper
for
PDO
database
object
.
Why
should
you
consider
using
Doctrine_DB
instead
of
PDO
?
<
br
\
><
br
\
>
1.
It
provides
efficient
eventlistener
architecture
,
hence
its
easy
to
add
new
aspects
to
existing
methods
like
on
-
demand
-
caching
<
br
\
><
br
\
>
2.
Doctrine_DB
lazy
-
connects
database
.
Creating
an
instance
of
Doctrine_DB
doesn
'
t
directly
connect
database
,
hence
Doctrine_DB
fits
perfectly
for
application
using
for
example
page
caching
.
<
br
\
><
br
\
>
3.
It
has
many
short
cuts
for
commonly
used
fetching
methods
like
Doctrine_DB
::
fetchOne
()
.
<
br
\
><
br
\
>
4.
Supports
PEAR
-
like
data
source
names
as
well
as
PDO
data
source
names
.
manual/documentation.php
View file @
0c94b003
...
@@ -144,7 +144,7 @@ $menu = array("Getting started" =>
...
@@ -144,7 +144,7 @@ $menu = array("Getting started" =>
"Getting record state"
,
"Getting record state"
,
"Getting object copy"
,
"Getting object copy"
,
"Serializing"
,
"Serializing"
,
"
Existence checking
"
,
"
Checking Existence
"
,
"Callbacks"
),
"Callbacks"
),
"Connection"
"Connection"
=>
array
(
"Introduction"
,
=>
array
(
"Introduction"
,
...
@@ -194,7 +194,8 @@ $menu = array("Getting started" =>
...
@@ -194,7 +194,8 @@ $menu = array("Getting started" =>
"DB"
=>
array
(
"DB"
=>
array
(
"Introduction"
,
"Introduction"
,
"Connecting to a database"
,
"Connecting to a database"
,
"Using event listeners"
),
"Using event listeners"
,
"Chaining listeners"
),
/**
/**
"Statement - <font color='red'>UNDER CONSTRUCTION</font>" => array("Introduction",
"Statement - <font color='red'>UNDER CONSTRUCTION</font>" => array("Introduction",
"Setting parameters",
"Setting parameters",
...
...
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