$this 和 $row PHP
$this with $row PHP
您好,下面的代码有效:
private function doPreEventStart {
$row = db_fetch_item("SELECT resultid FROM ResultPackage
where ResultPackage.slotid like {$this->curSlotId}
ORDER BY RAND() LIMIT 1");
$this->curResultId = $row['resultid'];
但是当我添加以下行时:
private function doPreEventStart($this->myusers as $user) {
$row = db_fetch_item("SELECT resultid FROM ResultPackage
where ResultPackage.slotid like {$this->curSlotId}
and ResultPackage.PackageID like {$user->packageid}
ORDER BY RAND() LIMIT 1");
$this->curResultId = $row['resultid'];
它不再在服务器上运行。我检查了 SQL 数据库,表确实存在。可能有什么问题?谢谢多布罗
我很确定您的函数中的参数分配导致了问题。尝试将其设置为函数定义中的简单参数,但在调用函数时使用 $this->myUsers
等。
private function doPreEventStart($user) {
$row = db_fetch_item("SELECT resultid FROM ResultPackage
where ResultPackage.slotid like '%{$this->curSlotId}%'
and ResultPackage.PackageID like '%{$user->packageid}%'
ORDER BY RAND() LIMIT 1");
$this->curResultId = $row['resultid'];
}
您好,下面的代码有效:
private function doPreEventStart {
$row = db_fetch_item("SELECT resultid FROM ResultPackage
where ResultPackage.slotid like {$this->curSlotId}
ORDER BY RAND() LIMIT 1");
$this->curResultId = $row['resultid'];
但是当我添加以下行时:
private function doPreEventStart($this->myusers as $user) {
$row = db_fetch_item("SELECT resultid FROM ResultPackage
where ResultPackage.slotid like {$this->curSlotId}
and ResultPackage.PackageID like {$user->packageid}
ORDER BY RAND() LIMIT 1");
$this->curResultId = $row['resultid'];
它不再在服务器上运行。我检查了 SQL 数据库,表确实存在。可能有什么问题?谢谢多布罗
我很确定您的函数中的参数分配导致了问题。尝试将其设置为函数定义中的简单参数,但在调用函数时使用 $this->myUsers
等。
private function doPreEventStart($user) {
$row = db_fetch_item("SELECT resultid FROM ResultPackage
where ResultPackage.slotid like '%{$this->curSlotId}%'
and ResultPackage.PackageID like '%{$user->packageid}%'
ORDER BY RAND() LIMIT 1");
$this->curResultId = $row['resultid'];
}