Skip to content

Commit

Permalink
Merge pull request #164 from sunkan/issue-163
Browse files Browse the repository at this point in the history
Fix issue #163
  • Loading branch information
harikt authored Mar 4, 2018
2 parents 596fc78 + c6659bd commit 4680d0d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/AbstractExtendedPdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -979,4 +979,31 @@ protected function setQuoteName($driver)
return;
}
}

/**
*
* Retrieve a database connection attribute
*
* @param int $attribute
* @return mixed
*/
public function getAttribute($attribute)
{
$this->connect();
return $this->pdo->getAttribute($attribute);
}

/**
*
* Set a database connection attribute
*
* @param int $attribute
* @param mixed $value
* @return bool
*/
public function setAttribute($attribute, $value)
{
$this->connect();
return $this->pdo->setAttribute($attribute, $value);
}
}
12 changes: 12 additions & 0 deletions tests/ExtendedPdoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,4 +730,16 @@ public function testQuoteName()
$this->assertSame('[foo].[[bar][]', $pdo->quoteName('foo.[bar]'));

}

public function testGetAttribute()
{
$driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
$this->assertEquals('sqlite', $driver);
}

public function testSetAttribute()
{
$result = $this->pdo->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_NATURAL);
$this->assertTrue($result);
}
}

0 comments on commit 4680d0d

Please sign in to comment.