Commit afcdacf3 authored by Andreas Pohl's avatar Andreas Pohl Committed by Steve Müller

remove resource type checks

I am also of the opinion that the resource type checks are unhappy. We depend on driver internals.
parent 20561717
......@@ -48,16 +48,9 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
*/
public function __construct($dsn, $persistent = false)
{
$allowedResourceTypes = array(
'SQLAnywhere connection'
,'SQLAnywhere persistent connection ' //note the blank!
);
$this->connection = $persistent ? @sasql_pconnect($dsn) : @sasql_connect($dsn);
$resourceType = get_resource_type($this->connection);
if ( ! is_resource($this->connection) || !in_array($resourceType, $allowedResourceTypes, true)) {
if ( ! is_resource($this->connection)) {
throw SQLAnywhereException::fromSQLAnywhereError();
}
......
......@@ -42,11 +42,11 @@ class SQLAnywhereException extends AbstractDriverException
*/
public static function fromSQLAnywhereError($conn = null, $stmt = null)
{
if (null !== $conn && ! (is_resource($conn) && get_resource_type($conn) === 'SQLAnywhere connection')) {
if (null !== $conn && ! (is_resource($conn))) {
throw new \InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn);
}
if (null !== $stmt && ! (is_resource($stmt) && get_resource_type($stmt) === 'SQLAnywhere statement')) {
if (null !== $stmt && ! (is_resource($stmt))) {
throw new \InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt);
}
......
......@@ -74,21 +74,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
public function __construct($conn, $sql)
{
$allowedResourceTypes = array(
'SQLAnywhere connection'
,'SQLAnywhere persistent connection ' //note the blank!
);
$resourceType = get_resource_type($conn);
if ( ! is_resource($conn) || !in_array($resourceType, $allowedResourceTypes, true)) {
if ( ! is_resource($conn)) {
throw new SQLAnywhereException('Invalid SQL Anywhere connection resource: ' . $conn);
}
$this->conn = $conn;
$this->stmt = sasql_prepare($conn, $sql);
if ( ! is_resource($this->stmt) || get_resource_type($this->stmt) !== 'SQLAnywhere statement') {
if ( ! is_resource($this->stmt)) {
throw SQLAnywhereException::fromSQLAnywhereError($conn);
}
}
......@@ -202,7 +195,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
public function fetch($fetchMode = null)
{
if ( ! is_resource($this->result) || get_resource_type($this->result) !== 'SQLAnywhere result') {
if ( ! is_resource($this->result)) {
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment