@@ -20,27 +20,30 @@ public function clear(): bool;
2020
2121class CacheFactory
2222{
23- const PREFIX = 'phpcrudapi-%s- ' ;
23+ const PREFIX = 'phpcrudapi-%s-%s-%s- ' ;
2424
25- private static function getPrefix (): String
25+ private static function getPrefix (Config $ config ): String
2626 {
27- return sprintf (self ::PREFIX , substr (md5 (__FILE__ ), 0 , 8 ));
27+ $ driver = $ config ->getDriver ();
28+ $ database = $ config ->getDatabase ();
29+ $ filehash = substr (md5 (__FILE__ ), 0 , 8 );
30+ return sprintf (self ::PREFIX , $ driver , $ database , $ filehash );
2831 }
2932
3033 public static function create (Config $ config ): Cache
3134 {
3235 switch ($ config ->getCacheType ()) {
3336 case 'TempFile ' :
34- $ cache = new TempFileCache (self ::getPrefix (), $ config ->getCachePath ());
37+ $ cache = new TempFileCache (self ::getPrefix ($ config ), $ config ->getCachePath ());
3538 break ;
3639 case 'Redis ' :
37- $ cache = new RedisCache (self ::getPrefix (), $ config ->getCachePath ());
40+ $ cache = new RedisCache (self ::getPrefix ($ config ), $ config ->getCachePath ());
3841 break ;
3942 case 'Memcache ' :
40- $ cache = new MemcacheCache (self ::getPrefix (), $ config ->getCachePath ());
43+ $ cache = new MemcacheCache (self ::getPrefix ($ config ), $ config ->getCachePath ());
4144 break ;
4245 case 'Memcached ' :
43- $ cache = new MemcachedCache (self ::getPrefix (), $ config ->getCachePath ());
46+ $ cache = new MemcachedCache (self ::getPrefix ($ config ), $ config ->getCachePath ());
4447 break ;
4548 default :
4649 $ cache = new NoCache ();
@@ -1368,7 +1371,7 @@ public function convertColumnName(ReflectedColumn $column, $value): String
13681371 case 'pgsql ' :
13691372 return "encode( $ value::bytea, 'base64') as $ value " ;
13701373 case 'sqlsrv ' :
1371- return "CAST(N'' AS XML). value('xs:base64Binary(xs:hexBinary(sql:column( $ value)))', 'VARCHAR(MAX)') as $ value " ;
1374+ return "CASE WHEN $ value IS NULL THEN NULL ELSE (SELECT CAST( $ value as varbinary(max)) FOR XML PATH(''), BINARY BASE64) END as $ value " ;
13721375
13731376 }
13741377 }
@@ -2579,6 +2582,9 @@ public function __construct(String $driver)
25792582 ],
25802583 'sqlsrv ' => [
25812584 'boolean ' => 'bit ' ,
2585+ 'varchar ' => 'nvarchar ' ,
2586+ 'clob ' => 'ntext ' ,
2587+ 'blob ' => 'image ' ,
25822588 ],
25832589 ];
25842590
@@ -2651,18 +2657,17 @@ public function __construct(String $driver)
26512657 'datetime ' => 'timestamp ' ,
26522658 'datetime2 ' => 'timestamp ' ,
26532659 'float ' => 'double ' ,
2654- 'image ' => 'varbinary ' ,
2660+ 'image ' => 'blob ' ,
26552661 'int ' => 'integer ' ,
26562662 'money ' => 'decimal ' ,
2657- 'ntext ' => 'longnvarchar ' ,
2663+ 'ntext ' => 'clob ' ,
26582664 'smalldatetime ' => 'timestamp ' ,
26592665 'smallmoney ' => 'decimal ' ,
2660- 'text ' => 'longvarchar ' ,
2666+ 'text ' => 'clob ' ,
26612667 'timestamp ' => 'binary ' ,
2662- 'tinyint ' => 'tinyint ' ,
26632668 'udt ' => 'varbinary ' ,
26642669 'uniqueidentifier ' => 'char ' ,
2665- 'xml ' => 'longnvarchar ' ,
2670+ 'xml ' => 'clob ' ,
26662671 ],
26672672 ];
26682673
0 commit comments