/** * Get the PHP snippet for binding a value to a column. * Warning: duplicates logic from AdapterInterface::bindValue(). * Any code modification here must be ported there. */ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ") { $script = ''; if ($column->isTemporalType()) { $columnValueAccessor = $columnValueAccessor . " ? " . $columnValueAccessor . "->format(\"" . $this->getTimeStampFormatter() . "\") : null"; } elseif ($column->isLobType()) { // we always need to make sure that the stream is rewound, otherwise nothing will // get written to database. $script .= "\nif (is_resource({$columnValueAccessor})) {\n rewind({$columnValueAccessor});\n}"; } $script .= sprintf("\n\$stmt->bindValue(%s, %s, %s);", $identifier, $columnValueAccessor, PropelTypes::getPdoTypeString($column->getType())); return preg_replace('/^(.+)/m', $tab . '$1', $script); }
/** * @dataProvider provideMappingLobTypes */ public function testLobType($mappingType, $phpType, $isPhpPrimitiveType) { $domain = $this->getDomainMock(); $domain->expects($this->once())->method('setType')->with($this->equalTo($mappingType)); $domain->expects($this->any())->method('getType')->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); $column->setType($mappingType); $this->assertSame($phpType, $column->getPhpType()); $this->assertSame($isPhpPrimitiveType, $column->isPhpPrimitiveType()); $this->assertTrue($column->isLobType()); }