@@ -75,7 +75,7 @@ public function __construct(String $prefix, String $config)
7575 $ this ->memcache ->addServer ($ address , $ port );
7676 }
7777
78- protected function create (): stdClass
78+ protected function create () /*: \Memcache*/
7979 {
8080 return new \Memcache ();
8181 }
@@ -100,7 +100,7 @@ public function clear(): bool
100100
101101class MemcachedCache extends MemcacheCache
102102{
103- protected function create (): stdClass
103+ protected function create () /*: \Memcached*/
104104 {
105105 return new \Memcached ();
106106 }
@@ -440,6 +440,11 @@ public function isGeometry(): bool
440440 return $ this ->type == 'geometry ' ;
441441 }
442442
443+ public function isInteger (): bool
444+ {
445+ return in_array ($ this ->type , ['integer ' , 'bigint ' , 'smallint ' , 'tinyint ' ]);
446+ }
447+
443448 public function setPk ($ value ) /*: void*/
444449 {
445450 $ this ->pk = $ value ;
@@ -484,18 +489,15 @@ public function jsonSerialize()
484489
485490class ReflectedDatabase implements \JsonSerializable
486491{
487- private $ name ;
488492 private $ tableTypes ;
489493
490- public function __construct (String $ name , array $ tableTypes )
494+ public function __construct (array $ tableTypes )
491495 {
492- $ this ->name = $ name ;
493496 $ this ->tableTypes = $ tableTypes ;
494497 }
495498
496499 public static function fromReflection (GenericReflection $ reflection ): ReflectedDatabase
497500 {
498- $ name = $ reflection ->getDatabaseName ();
499501 $ tableTypes = [];
500502 foreach ($ reflection ->getTables () as $ table ) {
501503 $ tableName = $ table ['TABLE_NAME ' ];
@@ -505,19 +507,13 @@ public static function fromReflection(GenericReflection $reflection): ReflectedD
505507 }
506508 $ tableTypes [$ tableName ] = $ tableType ;
507509 }
508- return new ReflectedDatabase ($ name , $ tableTypes );
510+ return new ReflectedDatabase ($ tableTypes );
509511 }
510512
511513 public static function fromJson ( /* object */ $ json ): ReflectedDatabase
512514 {
513- $ name = $ json ->name ;
514515 $ tableTypes = (array ) $ json ->tables ;
515- return new ReflectedDatabase ($ name , $ tableTypes );
516- }
517-
518- public function getName (): String
519- {
520- return $ this ->name ;
516+ return new ReflectedDatabase ($ tableTypes );
521517 }
522518
523519 public function hasTable (String $ tableName ): bool
@@ -547,7 +543,6 @@ public function removeTable(String $tableName): bool
547543 public function serialize ()
548544 {
549545 return [
550- 'name ' => $ this ->name ,
551546 'tables ' => $ this ->tableTypes ,
552547 ];
553548 }
@@ -987,12 +982,11 @@ public function __construct(Router $router, Responder $responder, ReflectionServ
987982
988983 public function getDatabase (Request $ request ): Response
989984 {
990- $ name = $ this ->reflection ->getDatabaseName ();
991985 $ tables = [];
992986 foreach ($ this ->reflection ->getTableNames () as $ table ) {
993987 $ tables [] = $ this ->reflection ->getTable ($ table );
994988 }
995- $ database = ['name ' => $ name , ' tables ' => $ tables ];
989+ $ database = ['tables ' => $ tables ];
996990 return $ this ->responder ->success ($ database );
997991 }
998992
@@ -1701,6 +1695,8 @@ private function convertRecordValue($conversion, $value)
17011695 switch ($ conversion ) {
17021696 case 'boolean ' :
17031697 return $ value ? true : false ;
1698+ case 'integer ' :
1699+ return (int ) $ value ;
17041700 }
17051701 return $ value ;
17061702 }
@@ -1710,6 +1706,9 @@ private function getRecordValueConversion(ReflectedColumn $column): String
17101706 if (in_array ($ this ->driver , ['mysql ' , 'sqlsrv ' ]) && $ column ->isBoolean ()) {
17111707 return 'boolean ' ;
17121708 }
1709+ if ($ this ->driver == 'sqlsrv ' && $ column ->getType () == 'bigint ' ) {
1710+ return 'integer ' ;
1711+ }
17131712 return 'none ' ;
17141713 }
17151714
@@ -1818,6 +1817,7 @@ private function getOptions(): array
18181817 \PDO ::ATTR_PERSISTENT => true ,
18191818 ];
18201819 case 'sqlsrv ' :return $ options + [
1820+ \PDO ::SQLSRV_ATTR_DIRECT_QUERY => false ,
18211821 \PDO ::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true ,
18221822 ];
18231823 }
@@ -1886,7 +1886,11 @@ public function createSingle(ReflectedTable $table, array $columnValues) /*: ?St
18861886 $ stmt = $ this ->query ('SELECT LAST_INSERT_ID() ' , []);
18871887 break ;
18881888 }
1889- return $ stmt ->fetchColumn (0 );
1889+ $ pkValue = $ stmt ->fetchColumn (0 );
1890+ if ($ this ->driver == 'sqlsrv ' && $ table ->getPk ()->getType () == 'bigint ' ) {
1891+ return (int ) $ pkValue ;
1892+ }
1893+ return $ pkValue ;
18901894 }
18911895
18921896 public function selectSingle (ReflectedTable $ table , array $ columnNames , String $ id ) /*: ?array*/
@@ -3701,7 +3705,7 @@ private function isOperationOnColumnAllowed(String $operation, String $tableName
37013705 private function setPath (String $ tableName ) /*: void*/
37023706 {
37033707 $ table = $ this ->reflection ->getTable ($ tableName );
3704- $ type = $ table ->getType ($ tableName );
3708+ $ type = $ table ->getType ();
37053709 $ pk = $ table ->getPk ();
37063710 $ pkName = $ pk ? $ pk ->getName () : '' ;
37073711 foreach ($ this ->operations as $ operation => $ method ) {
@@ -3751,7 +3755,7 @@ private function setPath(String $tableName) /*: void*/
37513755 private function setComponentSchema (String $ tableName ) /*: void*/
37523756 {
37533757 $ table = $ this ->reflection ->getTable ($ tableName );
3754- $ type = $ table ->getType ($ tableName );
3758+ $ type = $ table ->getType ();
37553759 $ pk = $ table ->getPk ();
37563760 $ pkName = $ pk ? $ pk ->getName () : '' ;
37573761 foreach ($ this ->operations as $ operation => $ method ) {
@@ -3793,7 +3797,7 @@ private function setComponentSchema(String $tableName) /*: void*/
37933797 private function setComponentResponse (String $ tableName ) /*: void*/
37943798 {
37953799 $ table = $ this ->reflection ->getTable ($ tableName );
3796- $ type = $ table ->getType ($ tableName );
3800+ $ type = $ table ->getType ();
37973801 $ pk = $ table ->getPk ();
37983802 $ pkName = $ pk ? $ pk ->getName () : '' ;
37993803 foreach (['list ' , 'read ' ] as $ operation ) {
@@ -3818,7 +3822,7 @@ private function setComponentResponse(String $tableName) /*: void*/
38183822 private function setComponentRequestBody (String $ tableName ) /*: void*/
38193823 {
38203824 $ table = $ this ->reflection ->getTable ($ tableName );
3821- $ type = $ table ->getType ($ tableName );
3825+ $ type = $ table ->getType ();
38223826 $ pk = $ table ->getPk ();
38233827 $ pkName = $ pk ? $ pk ->getName () : '' ;
38243828 if ($ pkName && $ type == 'table ' ) {
0 commit comments