【发布时间】:2012-06-12 08:07:00
【问题描述】:
我在一个名为 SQLHandling 的类中创建了一个 SQL 函数 SQLquery
它看起来像这样:
/***********************************************************
* SQLquery takes a full SQL query and runs it
* If it fails it will return an error otherwise it will return
* the SQL query as given.
************************************************************/
function SQLquery($query) {
$q = mysql_query($query);
if(!$q) {
die(mysql_error());
return false;
} else {
return $q;
}
}
反正我可以在其他类函数中使用这个函数而不添加
$db = new SQLHandling();
$db->SQLquery($sql);
在我将使用它的每个功能中。
我知道我可以运行SQLHandling::SQLquery($sql);,但我正在努力避免这种情况。
【问题讨论】: