F3区分大小写映射器错误

时间:2017-04-12 15:59:50

标签: sql-server mapping fat-free-framework

我目前正在尝试使用Fat Free Framework与MS SQL Server的映射器:

    $reports = new DB\SQL\Mapper($f3->get('DB'),'Reports');

我收到以下错误日志:

PDOStatement:[Microsoft] [SQL Server的ODBC驱动程序11] [SQL Server]无效的对象名称'information_schema.columns'。

[C:/wamp32/www/lib/base.php:2032] Base->error(500,'PDOStatement: [Microsoft]
[ODBC Driver 11 for SQL Server][SQL Server]Invalid object name 'information_schema.columns'.')
[C:/wamp32/www/lib/db/sql.php:339] DB\SQL->exec('SELECT c.column_name AS field,c.data_type AS type,c.column_default AS defval,c.is_nullable AS nullable,t.constraint_type AS pkey FROM information_schema.columns AS c LEFT OUTER JOIN information_schema.key_column_usage AS k ON c.table_name=k.table_name AND c.column_name=k.column_name AND c.table_schema=k.table_schema AND c.table_catalog=k.table_catalog LEFT OUTER JOIN information_schema.table_constraints AS t ON k.table_name=t.table_name AND k.constraint_name=t.constraint_name AND k.table_schema=t.table_schema AND k.table_catalog=t.table_catalog WHERE c.table_name='Reports';',NULL,60)

它解压缩了SELECT查询,并尝试直接在服务器上运行它,并意识到这是一个区分大小写的问题,因为它在大写时运行时工作正常。

我的问题是我找不到如何绕过这个或强制大写查询。文档here没有提到这样的内容。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

这是lib / db / sql.php文件中的解决方案。

您可以在架构函数中将以下内容添加到受支持引擎的$ cmd数组中:

'sqlsrv'=>array('SELECT '.
                    'C.COLUMN_NAME AS FIELD,'.
                    'C.DATA_TYPE AS TYPE,'.
                    'C.COLUMN_DEFAULT AS DEFVAL,'.
                    'C.IS_NULLABLE AS NULLABLE,'.
                    'T.CONSTRAINT_TYPE AS PKEY '.
                'FROM INFORMATION_SCHEMA.COLUMNS AS C '.
                'LEFT OUTER JOIN '.
                    'INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS K '.
                    'ON '.
                        'C.TABLE_NAME=K.TABLE_NAME AND '.
                        'C.COLUMN_NAME=K.COLUMN_NAME AND '.
                        'C.TABLE_SCHEMA=K.TABLE_SCHEMA '.
                        ($this->dbname?
                            ('AND C.TABLE_CATALOG=K.TABLE_CATALOG '):'').
                'LEFT OUTER JOIN '.
                    'INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS T ON '.
                        'K.TABLE_NAME=T.TABLE_NAME AND '.
                        'K.CONSTRAINT_NAME=T.CONSTRAINT_NAME AND '.
                        'K.TABLE_SCHEMA=T.TABLE_SCHEMA '.
                        ($this->dbname?
                            ('AND K.TABLE_CATALOG=T.TABLE_CATALOG '):'').
                'WHERE '.
                    'C.TABLE_NAME='.$this->quote($table).
                    ($this->dbname?
                        (' AND C.TABLE_CATALOG='.
                            $this->quote($this->dbname)):'').
                ';',
                'FIELD','TYPE','DEFVAL','NULLABLE','YES','PKEY','PRIMARY KEY'),

希望它会有所帮助。