znt/module/bi/test/model/querysql.php

26 lines
1.2 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
/**
title=测试 biModel::querySQL();
timeout=0
cid=15212
- 测试有效SQL查询期望result为success @success
- 测试无效SQL语法期望result为fail @fail
- 测试空SQL语句期望result为fail @fail
- 测试不存在表的查询期望result为fail @fail
- 测试count查询期望result为success @success
*/
$bi = new biModelTest();
r($bi->querySQLTest('SELECT id FROM zt_user LIMIT 2', 'SELECT id FROM zt_user LIMIT 2', 'mysql')) && p('result') && e('success'); // 测试有效SQL查询
r($bi->querySQLTest('SELECT id FROM zt_user', 'SELECT * FORM invalid_syntax', 'mysql')) && p('result') && e('fail'); // 测试无效SQL语法
r($bi->querySQLTest('', '', 'mysql')) && p('result') && e('fail'); // 测试空SQL语句
r($bi->querySQLTest('SELECT * FROM non_existent_table', 'SELECT * FROM non_existent_table LIMIT 1', 'mysql')) && p('result') && e('fail'); // 测试不存在的表
r($bi->querySQLTest('SELECT count(*) as total FROM zt_user', 'SELECT count(*) as total FROM zt_user LIMIT 1', 'mysql')) && p('result') && e('success'); // 测试count查询