File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * @link http://www.yiiframework.com/
4
+ * @copyright Copyright (c) 2008 Yii Software LLC
5
+ * @license http://www.yiiframework.com/license/
6
+ */
7
+
8
+ namespace websightnl \yii2 \sybase ;
9
+
10
+ /**
11
+ * This is an extension of the default PDO class of Sybase drivers.
12
+ * It provides workarounds for improperly implemented functionalities of the Sybase drivers.
13
+ *
14
+ * @author Timur Ruziev <[email protected] >
15
+ * @since 2.0
16
+ */
17
+ class PDO extends \PDO
18
+ {
19
+ /**
20
+ * Returns value of the last inserted ID.
21
+ * @param string|null $sequence the sequence name. Defaults to null.
22
+ * @return integer last inserted ID value.
23
+ */
24
+ public function lastInsertId ($ sequence = null )
25
+ {
26
+ return $ this ->query ('SELECT @@IDENTITY ' )->fetchColumn ();
27
+ }
28
+
29
+ /**
30
+ * Retrieve a database connection attribute.
31
+ * It is necessary to override PDO's method as some MSSQL PDO driver (e.g. dblib) does not
32
+ * support getting attributes
33
+ * @param integer $attribute One of the PDO::ATTR_* constants.
34
+ * @return mixed A successful call returns the value of the requested PDO attribute.
35
+ * An unsuccessful call returns null.
36
+ */
37
+ public function getAttribute ($ attribute )
38
+ {
39
+ try {
40
+ return parent ::getAttribute ($ attribute );
41
+ } catch (\PDOException $ e ) {
42
+ switch ($ attribute ) {
43
+ case PDO ::ATTR_SERVER_VERSION :
44
+ return $ this ->query ("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR) " )->fetchColumn ();
45
+ default :
46
+ throw $ e ;
47
+ }
48
+ }
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments