\utilSql

读取Sql文件并返回可执行的sql语句

Summary

Methods
Properties
Constants
getSqlFromFile()
parseSql()
read_file()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getSqlFromFile()

getSqlFromFile(string  $sql_file = '', boolean  $string = false, array  $replace = array()) : mixed

从sql文件获取纯sql语句

Parameters

string $sql_file

sql文件路径

boolean $string

如果为真,则只返回一条sql语句,默认以数组形式返回

array $replace

替换前缀,如:['my' => 'me'],表示将表前缀"my"替换成"me" 这种前缀替换方法不一定准确,比如正常内容内有跟前缀相同的字符,也会被替换

Returns

mixed

parseSql()

parseSql(string  $content = '', boolean  $string = false, array  $replace = array()) : array|string

分割sql语句

Parameters

string $content

sql内容

boolean $string

如果为真,则只返回一条sql语句,默认以数组形式返回

array $replace

替换前缀,如:['my' => 'me'],表示将表前缀my替换成me

Returns

array|string —

除去注释之后的sql语句数组或一条语句

read_file()

read_file(  $filename) : string

读取文件内容

Parameters

$filename

文件名

Returns

string —

文件内容