|
@@ 70-93 (lines=24) @@
|
| 67 |
|
self::assertFalse($row['bool_col']); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
public function testBooleanConversionBoolParamEmulatedPrepares() |
| 71 |
|
{ |
| 72 |
|
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 73 |
|
|
| 74 |
|
// PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated in php 5.6. PDO::ATTR_EMULATE_PREPARES should |
| 75 |
|
// be used instead. so should only it be set when it is supported. |
| 76 |
|
if (PHP_VERSION_ID < 50600) { |
| 77 |
|
$this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
$platform = $this->_conn->getDatabasePlatform(); |
| 81 |
|
|
| 82 |
|
$stmt = $this->_conn->prepare('INSERT INTO dbal630 (bool_col) VALUES(?)'); |
| 83 |
|
$stmt->bindValue(1, $platform->convertBooleansToDatabaseValue('false'), PDO::PARAM_BOOL); |
| 84 |
|
$stmt->execute(); |
| 85 |
|
|
| 86 |
|
$id = $this->_conn->lastInsertId('dbal630_id_seq'); |
| 87 |
|
|
| 88 |
|
self::assertNotEmpty($id); |
| 89 |
|
|
| 90 |
|
$row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', array($id)); |
| 91 |
|
|
| 92 |
|
self::assertFalse($row['bool_col']); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
/** |
| 96 |
|
* @dataProvider booleanTypeConversionWithoutPdoTypeProvider |
|
@@ 98-123 (lines=26) @@
|
| 95 |
|
/** |
| 96 |
|
* @dataProvider booleanTypeConversionWithoutPdoTypeProvider |
| 97 |
|
*/ |
| 98 |
|
public function testBooleanConversionNullParamEmulatedPrepares( |
| 99 |
|
$statementValue, |
| 100 |
|
$databaseConvertedValue |
| 101 |
|
) { |
| 102 |
|
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 103 |
|
|
| 104 |
|
// PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated in php 5.6. PDO::ATTR_EMULATE_PREPARES should |
| 105 |
|
// be used instead. so should only it be set when it is supported. |
| 106 |
|
if (PHP_VERSION_ID < 50600) { |
| 107 |
|
$this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true); |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
$platform = $this->_conn->getDatabasePlatform(); |
| 111 |
|
|
| 112 |
|
$stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)'); |
| 113 |
|
$stmt->bindValue(1, $platform->convertBooleansToDatabaseValue($statementValue)); |
| 114 |
|
$stmt->execute(); |
| 115 |
|
|
| 116 |
|
$id = $this->_conn->lastInsertId('dbal630_allow_nulls_id_seq'); |
| 117 |
|
|
| 118 |
|
self::assertNotEmpty($id); |
| 119 |
|
|
| 120 |
|
$row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', array($id)); |
| 121 |
|
|
| 122 |
|
self::assertSame($databaseConvertedValue, $row['bool_col']); |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
/** |
| 126 |
|
* @dataProvider booleanTypeConversionUsingBooleanTypeProvider |
|
@@ 128-153 (lines=26) @@
|
| 125 |
|
/** |
| 126 |
|
* @dataProvider booleanTypeConversionUsingBooleanTypeProvider |
| 127 |
|
*/ |
| 128 |
|
public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInBindValue( |
| 129 |
|
$statementValue, |
| 130 |
|
$databaseConvertedValue |
| 131 |
|
) { |
| 132 |
|
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 133 |
|
|
| 134 |
|
// PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated in php 5.6. PDO::ATTR_EMULATE_PREPARES should |
| 135 |
|
// be used instead. so should only it be set when it is supported. |
| 136 |
|
if (PHP_VERSION_ID < 50600) { |
| 137 |
|
$this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true); |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
$platform = $this->_conn->getDatabasePlatform(); |
| 141 |
|
|
| 142 |
|
$stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)'); |
| 143 |
|
$stmt->bindValue(1, $platform->convertBooleansToDatabaseValue($statementValue), PDO::PARAM_BOOL); |
| 144 |
|
$stmt->execute(); |
| 145 |
|
|
| 146 |
|
$id = $this->_conn->lastInsertId('dbal630_allow_nulls_id_seq'); |
| 147 |
|
|
| 148 |
|
self::assertNotEmpty($id); |
| 149 |
|
|
| 150 |
|
$row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', array($id)); |
| 151 |
|
|
| 152 |
|
self::assertSame($databaseConvertedValue, $row['bool_col']); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
/** |
| 156 |
|
* Boolean conversion mapping provider |