我试图调用一个传递了变量的函数,但是它没有用。
public function Delete_Update($uid, $msg_id)
{
$sql = mysql_query("select uploads_grab from messages where msg_id='$msg_id' and uid_fk='$uid'");
$roww = mysql_fetch_array($sql);
$uploads_grab_id=$roww['uploads_grab'];
if ($uploads_grab_id != '0') {
$sq = mysql_query("delete from user_uploads_grab where id='$uploads_grab_id'");
}
$query = mysql_query("DELETE FROM `comments` WHERE msg_id_fk = '$msg_id' and cfid='$uid' ") or die(mysql_error());
$query = mysql_query("DELETE FROM `messages` WHERE msg_id = '$msg_id' and uid_fk='$uid'") or die(mysql_error());
after_del($uid,$msg_id,'wall_post');
return true;
}
在上面的代码中,我调用了一个函数after_del($uid,$msg_id,'wall_post');
,但它无法正常工作
after_del函数是
class delme
{
function after_del($uid,$delid,$type)
{
$sql=mysql_query("select created from messages where msg_id='$delid' and uid_fk='$uid'");
$roww=mysql_fetch_array($sql);
$created=$roww['created'];
$del_noti = mysql_query("DELETE FROM `notification` WHERE time_stamp = '$created' and owner_user_id='$uid'") or die(mysql_error());
$del_activity = mysql_query("DELETE FROM `activity` WHERE time_stamp = '$created' and owner_user_id='$uid'") or die(mysql_error());
}
}
$del_result=new delme();
答案 0 :(得分:3)
after_del与Delete_Update在同一个类中吗?如果是,那么您可以这样访问:
$this->after_del($uid,$msg_id,'wall_post');
或者,如果after_del属于同一个类但是是静态方法,那么访问如下:
self::after_del($uid,$msg_id,'wall_post');
如果在另一个类中将after_del定义为公共方法,则首先创建该类的对象并调用该对象的方法:
$otherClass = new OtherClass();
$otherClass->after_del($uid,$msg_id,'wall_post');
或者,如果将after_del定义为另一个类的静态公共方法,则将其调用为:
OtherClass::after_del($uid,$msg_id,'wall_post');