New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ddc 494 #285
Ddc 494 #285
Changes from 4 commits
d93be3c
7c8b5f1
8293cd6
1e69bc4
10ac29c
55d5986
352e217
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
/* | ||
* $Id$ | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. For more information, see | ||
* <http://www.doctrine-project.org>. | ||
*/ | ||
|
||
namespace Doctrine\DBAL\Driver\PDOIbmi; | ||
|
||
use Doctrine\DBAL\Connection; | ||
|
||
/** | ||
* Driver for the PDO IBM extension | ||
* | ||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong. the license is MIT (as said in the license header), not LGPL. |
||
* @link www.doctrine-project.com | ||
* @since 1.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong, |
||
* @version $Revision$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove that line |
||
* @author Benjamin Eberlei <kontakt@beberlei.de> | ||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> | ||
* @author Jonathan Wage <jonwage@gmail.com> | ||
* @author Roman Borschel <roman@code-factory.org> | ||
*/ | ||
class Driver implements \Doctrine\DBAL\Driver | ||
{ | ||
/** | ||
* Attempts to establish a connection with the underlying driver. | ||
* | ||
* @param array $params | ||
* @param string $username | ||
* @param string $password | ||
* @param array $driverOptions | ||
* @return \Doctrine\DBAL\Driver\Connection | ||
*/ | ||
public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) | ||
{ | ||
$conn = new PDOIbmiConnection( | ||
$this->_constructPdoDsn($params), | ||
$username, | ||
$password, | ||
$driverOptions | ||
); | ||
|
||
return $conn; | ||
} | ||
|
||
/** | ||
* Constructs the ODBC PDO DSN. | ||
* To make things simple the odbc dsn created in the machine | ||
* should be created with the same name of the database | ||
* | ||
* @return string The DSN. | ||
*/ | ||
private function _constructPdoDsn(array $params) | ||
{ | ||
return 'odbc:'.$params['dbname']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we name it PDO IBM ODBC instead? because for example DB2iSeriesPlatform + SchemaManager should work wiht PDO IBM or IBM DB2 extensions or not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably won't work, DB2iSeriesPlatform only works with iSeries as DB2Platform only works with DB2 for Linux/unix/Windows the table names and their structure are quite different. This is why I don't know if its even posible to make a generic DB2Platform for PDOIbm or Ibm BD2. |
||
} | ||
|
||
/** | ||
* Gets the DatabasePlatform instance that provides all the metadata about | ||
* the platform this driver connects to. | ||
* | ||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. | ||
*/ | ||
public function getDatabasePlatform() | ||
{ | ||
return new \Doctrine\DBAL\Platforms\DB2iSeriesPlatform; | ||
} | ||
|
||
/** | ||
* Gets the SchemaManager that can be used to inspect and change the underlying | ||
* database schema of the platform this driver connects to. | ||
* | ||
* @param \Doctrine\DBAL\Connection $conn | ||
* @return \Doctrine\DBAL\Schema\DB2SchemaManager | ||
*/ | ||
public function getSchemaManager(Connection $conn) | ||
{ | ||
return new \Doctrine\DBAL\Schema\DB2iSeriesSchemaManager($conn); | ||
} | ||
|
||
/** | ||
* Gets the name of the driver. | ||
* | ||
* Things are different in DB2 flavor, this implementation works for | ||
* DB2 iSeries and probably for z/OS | ||
* | ||
* @return string The name of the driver. | ||
*/ | ||
public function getName() | ||
{ | ||
return 'pdo_ibm_i'; | ||
} | ||
|
||
/** | ||
* Get the name of the database connected to for this driver. | ||
* | ||
* @param \Doctrine\DBAL\Connection $conn | ||
* @return string $database | ||
*/ | ||
public function getDatabase(\Doctrine\DBAL\Connection $conn) | ||
{ | ||
$params = $conn->getParams(); | ||
return $params['dbname']; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. For more information, see | ||
* <http://www.doctrine-project.org>. | ||
*/ | ||
|
||
namespace Doctrine\DBAL\Driver\PDOIbmi; | ||
|
||
use Doctrine\DBAL\Platforms\DB2iSeriesPlatform; | ||
|
||
/** | ||
* | ||
* @since 2.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since 2.5 |
||
*/ | ||
class PDOIbmiConnection extends \Doctrine\DBAL\Driver\PDOConnection { | ||
|
||
public function lastInsertId($name = null) { | ||
$stm = parent::prepare("SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1"); | ||
$stm->execute(); | ||
$result = $stm->fetch(parent::FETCH_ASSOC); | ||
return $result['VAL']; | ||
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this line and the empty line below, this are SVN relicts