Skip to content

Commit 06a83c1

Browse files
committed
Created constructor for DB credentials.
1 parent c109eec commit 06a83c1

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

ToolkitApi/Odbcsupp.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,40 @@
88
*/
99
class odbcsupp
1010
{
11-
private $last_errorcode = '';
12-
private $last_errormsg = '';
11+
private $last_errorcode;
12+
private $last_errormsg;
13+
private $database;
14+
private $user;
15+
private $password;
16+
private $options;
1317

1418
/**
15-
*
16-
* @todo should perhaps handle this method differently if $options are not passed
17-
*
1819
* @param $database
1920
* @param $user
2021
* @param $password
2122
* @param null $options
23+
*/
24+
public function __construct($database, $user, $password, $options = null)
25+
{
26+
$this->database = $database;
27+
$this->user = $user;
28+
$this->password = $password;
29+
$this->options = $options;
30+
}
31+
32+
/**
33+
*
34+
* @todo should perhaps handle this method differently if $options are not passed
35+
*
2236
* @return bool|resource
2337
*/
24-
public function connect($database, $user, $password, $options = null)
38+
public function connect()
2539
{
26-
if ($options) {
27-
if ((isset($options['persistent'])) && $options['persistent']) {
28-
$conn = odbc_pconnect($database, $user, $password);
40+
if ($this->options) {
41+
if ((isset($this->options['persistent'])) && $this->options['persistent']) {
42+
$conn = odbc_pconnect($this->database, $this->user, $this->password);
2943
} else {
30-
$conn = odbc_connect($database, $user, $password);
44+
$conn = odbc_connect($this->database, $this->user, $this->password);
3145
}
3246

3347
if (is_resource($conn)) {

0 commit comments

Comments
 (0)