OOP and connecting to multiple databases using PDO
up vote
2
down vote
favorite
I'm just starting to learn OOP and I've setup a class to handle the database connections and wanted to check if I'm going about this the right way.
My website is already using PDO for prepared statements but it's procedural code otherwise. The site connects to multiple databases and one of the databases has two connections for separate privileges.
I have created a Dsn class which contains a method for each connection. My config file instantiates the class and opens all the connections using the methods and passing params where necessary. I'll put the code below but just wanted to check if connecting to multiple databases in this way through a single class follows best practices for OOP.
config.php
$dbh = new Dsn;
$pdo = $dbh->connnect1Read(NAME1, USER2, PASS2);
$pdo2 = $dbh->connnect2Write(NAME1, USER1, PASS1);
$pdo3 = $dbh->connnect3(USER2, PASS2);
$pdo4 = $dbh->connnect4(USER3, PASS3);
$pdo5 = $dbh->connnect5(USER4, PASS4);
dsn.php
class Dsn
{
private $host = 'localhost';
private $charset = 'utf8mb4';
private $dbName1;
private $userName1;
private $userPass1;
private $dbName2 = 'db2';
private $userName2;
private $userPass2;
private $dbName3 = 'db3';
private $userName3;
private $userPass3;
private $dbName4 = 'db4';
private $userName4;
private $userPass4;
private $opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
public function connnect1Read($dbName, $userName, $userPass)
{
$this->dbName1 = $dbName;
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo1 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo1;
}
public function connnect2Write($dbName1, $userName, $userPass)
{
$this->dbName1 = $dbName1;
$this->userName1 = $userName;
$this->userPass1 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo2 = new PDO($dsn, $this->userName1, $this->userPass1, $this->opt);
return $pdo2;
}
public function connnect3($userName, $userPass)
{
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName2 . ";charset=" . $this->charset . "";
$pdo4 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo3;
}
public function connnect4($userName, $userPass)
{
$this->userName3 = $userName;
$this->userPass3 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName3 . ";charset=" . $this->charset . "";
$pdo5 = new PDO($dsn, $this->userName3, $this->userPass3, $this->opt);
return $pdo4;
}
public function connnect5($userName, $userPass)
{
$this->userName4 = $userName;
$this->userPass4 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName4 . ";charset=" . $this->charset . "";
$pdo3 = new PDO($dsn, $this->userName4, $this->userPass4, $this->opt);
return $pdo5;
}
}
php object-oriented pdo
New contributor
add a comment |
up vote
2
down vote
favorite
I'm just starting to learn OOP and I've setup a class to handle the database connections and wanted to check if I'm going about this the right way.
My website is already using PDO for prepared statements but it's procedural code otherwise. The site connects to multiple databases and one of the databases has two connections for separate privileges.
I have created a Dsn class which contains a method for each connection. My config file instantiates the class and opens all the connections using the methods and passing params where necessary. I'll put the code below but just wanted to check if connecting to multiple databases in this way through a single class follows best practices for OOP.
config.php
$dbh = new Dsn;
$pdo = $dbh->connnect1Read(NAME1, USER2, PASS2);
$pdo2 = $dbh->connnect2Write(NAME1, USER1, PASS1);
$pdo3 = $dbh->connnect3(USER2, PASS2);
$pdo4 = $dbh->connnect4(USER3, PASS3);
$pdo5 = $dbh->connnect5(USER4, PASS4);
dsn.php
class Dsn
{
private $host = 'localhost';
private $charset = 'utf8mb4';
private $dbName1;
private $userName1;
private $userPass1;
private $dbName2 = 'db2';
private $userName2;
private $userPass2;
private $dbName3 = 'db3';
private $userName3;
private $userPass3;
private $dbName4 = 'db4';
private $userName4;
private $userPass4;
private $opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
public function connnect1Read($dbName, $userName, $userPass)
{
$this->dbName1 = $dbName;
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo1 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo1;
}
public function connnect2Write($dbName1, $userName, $userPass)
{
$this->dbName1 = $dbName1;
$this->userName1 = $userName;
$this->userPass1 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo2 = new PDO($dsn, $this->userName1, $this->userPass1, $this->opt);
return $pdo2;
}
public function connnect3($userName, $userPass)
{
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName2 . ";charset=" . $this->charset . "";
$pdo4 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo3;
}
public function connnect4($userName, $userPass)
{
$this->userName3 = $userName;
$this->userPass3 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName3 . ";charset=" . $this->charset . "";
$pdo5 = new PDO($dsn, $this->userName3, $this->userPass3, $this->opt);
return $pdo4;
}
public function connnect5($userName, $userPass)
{
$this->userName4 = $userName;
$this->userPass4 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName4 . ";charset=" . $this->charset . "";
$pdo3 = new PDO($dsn, $this->userName4, $this->userPass4, $this->opt);
return $pdo5;
}
}
php object-oriented pdo
New contributor
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm just starting to learn OOP and I've setup a class to handle the database connections and wanted to check if I'm going about this the right way.
My website is already using PDO for prepared statements but it's procedural code otherwise. The site connects to multiple databases and one of the databases has two connections for separate privileges.
I have created a Dsn class which contains a method for each connection. My config file instantiates the class and opens all the connections using the methods and passing params where necessary. I'll put the code below but just wanted to check if connecting to multiple databases in this way through a single class follows best practices for OOP.
config.php
$dbh = new Dsn;
$pdo = $dbh->connnect1Read(NAME1, USER2, PASS2);
$pdo2 = $dbh->connnect2Write(NAME1, USER1, PASS1);
$pdo3 = $dbh->connnect3(USER2, PASS2);
$pdo4 = $dbh->connnect4(USER3, PASS3);
$pdo5 = $dbh->connnect5(USER4, PASS4);
dsn.php
class Dsn
{
private $host = 'localhost';
private $charset = 'utf8mb4';
private $dbName1;
private $userName1;
private $userPass1;
private $dbName2 = 'db2';
private $userName2;
private $userPass2;
private $dbName3 = 'db3';
private $userName3;
private $userPass3;
private $dbName4 = 'db4';
private $userName4;
private $userPass4;
private $opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
public function connnect1Read($dbName, $userName, $userPass)
{
$this->dbName1 = $dbName;
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo1 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo1;
}
public function connnect2Write($dbName1, $userName, $userPass)
{
$this->dbName1 = $dbName1;
$this->userName1 = $userName;
$this->userPass1 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo2 = new PDO($dsn, $this->userName1, $this->userPass1, $this->opt);
return $pdo2;
}
public function connnect3($userName, $userPass)
{
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName2 . ";charset=" . $this->charset . "";
$pdo4 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo3;
}
public function connnect4($userName, $userPass)
{
$this->userName3 = $userName;
$this->userPass3 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName3 . ";charset=" . $this->charset . "";
$pdo5 = new PDO($dsn, $this->userName3, $this->userPass3, $this->opt);
return $pdo4;
}
public function connnect5($userName, $userPass)
{
$this->userName4 = $userName;
$this->userPass4 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName4 . ";charset=" . $this->charset . "";
$pdo3 = new PDO($dsn, $this->userName4, $this->userPass4, $this->opt);
return $pdo5;
}
}
php object-oriented pdo
New contributor
I'm just starting to learn OOP and I've setup a class to handle the database connections and wanted to check if I'm going about this the right way.
My website is already using PDO for prepared statements but it's procedural code otherwise. The site connects to multiple databases and one of the databases has two connections for separate privileges.
I have created a Dsn class which contains a method for each connection. My config file instantiates the class and opens all the connections using the methods and passing params where necessary. I'll put the code below but just wanted to check if connecting to multiple databases in this way through a single class follows best practices for OOP.
config.php
$dbh = new Dsn;
$pdo = $dbh->connnect1Read(NAME1, USER2, PASS2);
$pdo2 = $dbh->connnect2Write(NAME1, USER1, PASS1);
$pdo3 = $dbh->connnect3(USER2, PASS2);
$pdo4 = $dbh->connnect4(USER3, PASS3);
$pdo5 = $dbh->connnect5(USER4, PASS4);
dsn.php
class Dsn
{
private $host = 'localhost';
private $charset = 'utf8mb4';
private $dbName1;
private $userName1;
private $userPass1;
private $dbName2 = 'db2';
private $userName2;
private $userPass2;
private $dbName3 = 'db3';
private $userName3;
private $userPass3;
private $dbName4 = 'db4';
private $userName4;
private $userPass4;
private $opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
public function connnect1Read($dbName, $userName, $userPass)
{
$this->dbName1 = $dbName;
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo1 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo1;
}
public function connnect2Write($dbName1, $userName, $userPass)
{
$this->dbName1 = $dbName1;
$this->userName1 = $userName;
$this->userPass1 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName1 . ";charset=" . $this->charset . "";
$pdo2 = new PDO($dsn, $this->userName1, $this->userPass1, $this->opt);
return $pdo2;
}
public function connnect3($userName, $userPass)
{
$this->userName2 = $userName;
$this->userPass2 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName2 . ";charset=" . $this->charset . "";
$pdo4 = new PDO($dsn, $this->userName2, $this->userPass2, $this->opt);
return $pdo3;
}
public function connnect4($userName, $userPass)
{
$this->userName3 = $userName;
$this->userPass3 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName3 . ";charset=" . $this->charset . "";
$pdo5 = new PDO($dsn, $this->userName3, $this->userPass3, $this->opt);
return $pdo4;
}
public function connnect5($userName, $userPass)
{
$this->userName4 = $userName;
$this->userPass4 = $userPass;
$dsn = "mysql:host=" . $this->host . ";dbname=" . $this->dbName4 . ";charset=" . $this->charset . "";
$pdo3 = new PDO($dsn, $this->userName4, $this->userPass4, $this->opt);
return $pdo5;
}
}
php object-oriented pdo
php object-oriented pdo
New contributor
New contributor
New contributor
asked 2 days ago
Jordan Turner
111
111
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
This is not how things are done in the programming world. You don't write a dozen functions doing the same thing. You write just one function.
Speaking of OOP, there is no use for it here. Given your class consists of just one method, just make it a function:
function connnect($dbName, $userName, $userPass)
{
$host = 'localhost';
$charset = 'utf8mb4';
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$dsn = "mysql:host=$host;dbname=$dbName;charset=$charset";
return new PDO($dsn, $userName, $userPass, $opt);
}
and then create your connections:
$dbRead = connnect(NAME1, USER2, PASS2);
$dbWrte = connnect(NAME1, USER1, PASS1);
$db3 = connnect(NAME3, USER2, PASS2);
$db4 = connnect(NAME4, USER3, PASS3);
$db5 = connnect(NAME5, USER4, PASS4);
Thanks you. I do feel like a bit of an idiot now you've made it that simple and I understand that a class isn't necessary but I was just looking for some advice on the best practices of handling multiple connections using OOP PHP. I realise I should just use a single function or method now. I find some of the concepts of OOP a bit strange so I would like to practice it to try and understand it more. I've watched some tutorials on OOP and MVC pattern so I was trying to keep everything separate so that's why my plan was to use a class to handle the connections.
– Jordan Turner
2 days ago
Speaking of multiple connections, there is nothing much OOP can help you with. You just need multiple instances of PDO, and how do you get them doesn't make too much difference. OOP is more about organizing the code, but here there is not so much to organize
– Your Common Sense
2 days ago
Alright, well I'll take that onboard. Thanks again for your feedback.
– Jordan Turner
2 days ago
OOP will be involved in how you're going to use these connections though.
– Your Common Sense
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
This is not how things are done in the programming world. You don't write a dozen functions doing the same thing. You write just one function.
Speaking of OOP, there is no use for it here. Given your class consists of just one method, just make it a function:
function connnect($dbName, $userName, $userPass)
{
$host = 'localhost';
$charset = 'utf8mb4';
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$dsn = "mysql:host=$host;dbname=$dbName;charset=$charset";
return new PDO($dsn, $userName, $userPass, $opt);
}
and then create your connections:
$dbRead = connnect(NAME1, USER2, PASS2);
$dbWrte = connnect(NAME1, USER1, PASS1);
$db3 = connnect(NAME3, USER2, PASS2);
$db4 = connnect(NAME4, USER3, PASS3);
$db5 = connnect(NAME5, USER4, PASS4);
Thanks you. I do feel like a bit of an idiot now you've made it that simple and I understand that a class isn't necessary but I was just looking for some advice on the best practices of handling multiple connections using OOP PHP. I realise I should just use a single function or method now. I find some of the concepts of OOP a bit strange so I would like to practice it to try and understand it more. I've watched some tutorials on OOP and MVC pattern so I was trying to keep everything separate so that's why my plan was to use a class to handle the connections.
– Jordan Turner
2 days ago
Speaking of multiple connections, there is nothing much OOP can help you with. You just need multiple instances of PDO, and how do you get them doesn't make too much difference. OOP is more about organizing the code, but here there is not so much to organize
– Your Common Sense
2 days ago
Alright, well I'll take that onboard. Thanks again for your feedback.
– Jordan Turner
2 days ago
OOP will be involved in how you're going to use these connections though.
– Your Common Sense
2 days ago
add a comment |
up vote
2
down vote
This is not how things are done in the programming world. You don't write a dozen functions doing the same thing. You write just one function.
Speaking of OOP, there is no use for it here. Given your class consists of just one method, just make it a function:
function connnect($dbName, $userName, $userPass)
{
$host = 'localhost';
$charset = 'utf8mb4';
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$dsn = "mysql:host=$host;dbname=$dbName;charset=$charset";
return new PDO($dsn, $userName, $userPass, $opt);
}
and then create your connections:
$dbRead = connnect(NAME1, USER2, PASS2);
$dbWrte = connnect(NAME1, USER1, PASS1);
$db3 = connnect(NAME3, USER2, PASS2);
$db4 = connnect(NAME4, USER3, PASS3);
$db5 = connnect(NAME5, USER4, PASS4);
Thanks you. I do feel like a bit of an idiot now you've made it that simple and I understand that a class isn't necessary but I was just looking for some advice on the best practices of handling multiple connections using OOP PHP. I realise I should just use a single function or method now. I find some of the concepts of OOP a bit strange so I would like to practice it to try and understand it more. I've watched some tutorials on OOP and MVC pattern so I was trying to keep everything separate so that's why my plan was to use a class to handle the connections.
– Jordan Turner
2 days ago
Speaking of multiple connections, there is nothing much OOP can help you with. You just need multiple instances of PDO, and how do you get them doesn't make too much difference. OOP is more about organizing the code, but here there is not so much to organize
– Your Common Sense
2 days ago
Alright, well I'll take that onboard. Thanks again for your feedback.
– Jordan Turner
2 days ago
OOP will be involved in how you're going to use these connections though.
– Your Common Sense
2 days ago
add a comment |
up vote
2
down vote
up vote
2
down vote
This is not how things are done in the programming world. You don't write a dozen functions doing the same thing. You write just one function.
Speaking of OOP, there is no use for it here. Given your class consists of just one method, just make it a function:
function connnect($dbName, $userName, $userPass)
{
$host = 'localhost';
$charset = 'utf8mb4';
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$dsn = "mysql:host=$host;dbname=$dbName;charset=$charset";
return new PDO($dsn, $userName, $userPass, $opt);
}
and then create your connections:
$dbRead = connnect(NAME1, USER2, PASS2);
$dbWrte = connnect(NAME1, USER1, PASS1);
$db3 = connnect(NAME3, USER2, PASS2);
$db4 = connnect(NAME4, USER3, PASS3);
$db5 = connnect(NAME5, USER4, PASS4);
This is not how things are done in the programming world. You don't write a dozen functions doing the same thing. You write just one function.
Speaking of OOP, there is no use for it here. Given your class consists of just one method, just make it a function:
function connnect($dbName, $userName, $userPass)
{
$host = 'localhost';
$charset = 'utf8mb4';
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$dsn = "mysql:host=$host;dbname=$dbName;charset=$charset";
return new PDO($dsn, $userName, $userPass, $opt);
}
and then create your connections:
$dbRead = connnect(NAME1, USER2, PASS2);
$dbWrte = connnect(NAME1, USER1, PASS1);
$db3 = connnect(NAME3, USER2, PASS2);
$db4 = connnect(NAME4, USER3, PASS3);
$db5 = connnect(NAME5, USER4, PASS4);
edited 2 days ago
Sᴀᴍ Onᴇᴌᴀ
7,67561748
7,67561748
answered 2 days ago
Your Common Sense
3,186526
3,186526
Thanks you. I do feel like a bit of an idiot now you've made it that simple and I understand that a class isn't necessary but I was just looking for some advice on the best practices of handling multiple connections using OOP PHP. I realise I should just use a single function or method now. I find some of the concepts of OOP a bit strange so I would like to practice it to try and understand it more. I've watched some tutorials on OOP and MVC pattern so I was trying to keep everything separate so that's why my plan was to use a class to handle the connections.
– Jordan Turner
2 days ago
Speaking of multiple connections, there is nothing much OOP can help you with. You just need multiple instances of PDO, and how do you get them doesn't make too much difference. OOP is more about organizing the code, but here there is not so much to organize
– Your Common Sense
2 days ago
Alright, well I'll take that onboard. Thanks again for your feedback.
– Jordan Turner
2 days ago
OOP will be involved in how you're going to use these connections though.
– Your Common Sense
2 days ago
add a comment |
Thanks you. I do feel like a bit of an idiot now you've made it that simple and I understand that a class isn't necessary but I was just looking for some advice on the best practices of handling multiple connections using OOP PHP. I realise I should just use a single function or method now. I find some of the concepts of OOP a bit strange so I would like to practice it to try and understand it more. I've watched some tutorials on OOP and MVC pattern so I was trying to keep everything separate so that's why my plan was to use a class to handle the connections.
– Jordan Turner
2 days ago
Speaking of multiple connections, there is nothing much OOP can help you with. You just need multiple instances of PDO, and how do you get them doesn't make too much difference. OOP is more about organizing the code, but here there is not so much to organize
– Your Common Sense
2 days ago
Alright, well I'll take that onboard. Thanks again for your feedback.
– Jordan Turner
2 days ago
OOP will be involved in how you're going to use these connections though.
– Your Common Sense
2 days ago
Thanks you. I do feel like a bit of an idiot now you've made it that simple and I understand that a class isn't necessary but I was just looking for some advice on the best practices of handling multiple connections using OOP PHP. I realise I should just use a single function or method now. I find some of the concepts of OOP a bit strange so I would like to practice it to try and understand it more. I've watched some tutorials on OOP and MVC pattern so I was trying to keep everything separate so that's why my plan was to use a class to handle the connections.
– Jordan Turner
2 days ago
Thanks you. I do feel like a bit of an idiot now you've made it that simple and I understand that a class isn't necessary but I was just looking for some advice on the best practices of handling multiple connections using OOP PHP. I realise I should just use a single function or method now. I find some of the concepts of OOP a bit strange so I would like to practice it to try and understand it more. I've watched some tutorials on OOP and MVC pattern so I was trying to keep everything separate so that's why my plan was to use a class to handle the connections.
– Jordan Turner
2 days ago
Speaking of multiple connections, there is nothing much OOP can help you with. You just need multiple instances of PDO, and how do you get them doesn't make too much difference. OOP is more about organizing the code, but here there is not so much to organize
– Your Common Sense
2 days ago
Speaking of multiple connections, there is nothing much OOP can help you with. You just need multiple instances of PDO, and how do you get them doesn't make too much difference. OOP is more about organizing the code, but here there is not so much to organize
– Your Common Sense
2 days ago
Alright, well I'll take that onboard. Thanks again for your feedback.
– Jordan Turner
2 days ago
Alright, well I'll take that onboard. Thanks again for your feedback.
– Jordan Turner
2 days ago
OOP will be involved in how you're going to use these connections though.
– Your Common Sense
2 days ago
OOP will be involved in how you're going to use these connections though.
– Your Common Sense
2 days ago
add a comment |
Jordan Turner is a new contributor. Be nice, and check out our Code of Conduct.
Jordan Turner is a new contributor. Be nice, and check out our Code of Conduct.
Jordan Turner is a new contributor. Be nice, and check out our Code of Conduct.
Jordan Turner is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207798%2foop-and-connecting-to-multiple-databases-using-pdo%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown