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
fbb5a532
Commit
fbb5a532
authored
May 07, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
46e01370
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
28 deletions
+27
-28
Connection management - Connection-component binding.php
.../Connection management - Connection-component binding.php
+7
-7
Connection management - Lazy-connecting to database.php
...s/Connection management - Lazy-connecting to database.php
+3
-3
Connection management - Managing connections.php
manual/docs/Connection management - Managing connections.php
+1
-1
Connection management - Opening a new connection.php
...docs/Connection management - Opening a new connection.php
+16
-17
No files found.
manual/docs/Connection management - Connection-component binding.php
View file @
fbb5a532
...
...
@@ -5,20 +5,20 @@ or data is being fetched from the table the component is pointing at Doctrine wi
<
code
type
=
"php"
>
\
$conn
=
\
$manager
->
openConnection
(
new
PDO
(
'dsn'
,
'username'
,
'password'
),
'connection 1'
);
$conn
=
$manager
->
openConnection
(
new
PDO
(
'dsn'
,
'username'
,
'password'
),
'connection 1'
);
\
$conn2
=
\
$manager
->
openConnection
(
new
PDO
(
'dsn2'
,
'username2'
,
'password2'
),
'connection 2'
);
$conn2
=
$manager
->
openConnection
(
new
PDO
(
'dsn2'
,
'username2'
,
'password2'
),
'connection 2'
);
\
$manager
->
bindComponent
(
'User'
,
'connection 1'
);
$manager
->
bindComponent
(
'User'
,
'connection 1'
);
\
$manager
->
bindComponent
(
'Group'
,
'connection 2'
);
$manager
->
bindComponent
(
'Group'
,
'connection 2'
);
\
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
();
// Doctrine uses 'connection 1' for fetching here
\
$users
=
\
$q
->
from
(
'User u'
)
->
where
(
'u.id IN (1,2,3)'
)
->
execute
();
$users
=
$q
->
from
(
'User u'
)
->
where
(
'u.id IN (1,2,3)'
)
->
execute
();
// Doctrine uses 'connection 2' for fetching here
\
$groups
=
\
$q
->
from
(
'Group g'
)
->
where
(
'g.id IN (1,2,3)'
)
->
execute
();
$groups
=
$q
->
from
(
'Group g'
)
->
where
(
'g.id IN (1,2,3)'
)
->
execute
();
?>
</code>
manual/docs/Connection management - Lazy-connecting to database.php
View file @
fbb5a532
...
...
@@ -10,15 +10,15 @@ when using for example page caching, hence not actually needing a database conne
<
code
type
=
"php"
>
// we may use PDO / PEAR like DSN
// here we use PEAR like DSN
\
$dbh
=
new
Doctrine_Db
(
'mysql://username:password@localhost/test'
);
$dbh
=
new
Doctrine_Db
(
'mysql://username:password@localhost/test'
);
// !! no actual database connection yet !!
// initalize a new Doctrine_Connection
\
$conn
=
Doctrine_Manager
::
connection
(
\
$dbh
);
$conn
=
Doctrine_Manager
::
connection
(
$dbh
);
// !! no actual database connection yet !!
// connects database and performs a query
\
$conn
->
query
(
'FROM User u'
);
$conn
->
query
(
'FROM User u'
);
?>
</code>
manual/docs/Connection management - Managing connections.php
View file @
fbb5a532
...
...
@@ -12,7 +12,7 @@ $manager = Doctrine_Manager::getInstance();
// open first connection
\
$conn
=
\
$manager
->
openConnection
(
new
PDO
(
'dsn'
,
'username'
,
'password'
),
'connection 1'
);
$conn
=
$manager
->
openConnection
(
new
PDO
(
'dsn'
,
'username'
,
'password'
),
'connection 1'
);
</
code
>
...
...
manual/docs/Connection management - Opening a new connection.php
View file @
fbb5a532
...
...
@@ -4,16 +4,16 @@ Opening a new database connection in Doctrine is very easy. If you wish to use P
<
code
type
=
"php"
>
\
$dsn
=
'mysql:dbname=testdb;host=127.0.0.1'
;
\
$user
=
'dbuser'
;
\
$password
=
'dbpass'
;
$dsn
=
'mysql:dbname=testdb;host=127.0.0.1'
;
$user
=
'dbuser'
;
$password
=
'dbpass'
;
try
{
\
$dbh
=
new
PDO
(
\
$dsn
,
\
$user
,
\
$password
);
}
catch
(
PDOException
\
$e
)
{
echo
'Connection failed: '
.
\
$e
->
getMessage
();
$dbh
=
new
PDO
(
$dsn
,
$user
,
$password
);
}
catch
(
PDOException
$e
)
{
echo
'Connection failed: '
.
$e
->
getMessage
();
}
?>
</code>
</
code
>
...
...
@@ -22,16 +22,16 @@ If your database extension isn't supported by PDO you can use special Doctrine_A
<code type="php">
\
$dsn = 'db2:dbname=testdb;host=127.0.0.1';
\
$user = 'dbuser';
\
$password = 'dbpass';
$dsn = '
db2
:
dbname
=
testdb
;
host
=
127.0
.
0.1
';
$user = '
dbuser
';
$password = '
dbpass
';
try {
\$dbh = Doctrine_Adapter::connect(\$dsn, \$user, \
$password);
} catch (PDOException
\
$e) {
echo 'Connection failed: ' .
\
$e->getMessage();
$dbh = Doctrine_Adapter::connect($dsn, $user,
$password);
} catch (PDOException $e) {
echo '
Connection
failed
:
'
.
$e
->
getMessage
();
}
?>
</code>
</
code
>
...
...
@@ -40,6 +40,5 @@ The next step is opening a new Doctrine_Connection.
<
code
type
=
"php"
>
\$conn = Doctrine_Manager::connection(\$dbh);
?>
</code>
$conn
=
Doctrine_Manager
::
connection
(
$dbh
);
</
code
>
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