我正在尝试用php7移植opencats,我遇到了这个问题,我在哪里错了?
https://github.com/opencats/OpenCATS
public function getDepartmentIDByName($departmentName, $companyID, $db)
{
/* (none) always has an ID of 0. */
if ($departmentName === '(none)')
{
return 0;
}
$sql = sprintf(
"SELECT
company_department_id AS departmentID
FROM
company_department
WHERE
name = %s
AND
company_id = %s
AND
site_id = %s",
$this->_db->makeQueryString($departmentName),
$companyID,
$this->_siteID
);
$rs = $db->getAssoc($sql);
if (empty($rs))
{
return 0;
}
return $rs['departmentID'];
}
完整的错误日志在这里。
[Wed May 29 00:02:20.990215 2019] [php7:error] [pid 6101] [client ::1:52241] PHP Fatal error: Uncaught Error: Using $this when not in object context in /var/www/html/opencats/lib/Contacts.php:788\nStack trace:\n#0 /var/www/html/opencats/lib/JobOrders.php(107): Contacts::getDepartmentIDByName('IT', '2', Object(DatabaseConnection))\n#1 /var/www/html/opencats/modules/joborders/JobOrdersUI.php(785): JobOrders->add('Super', '2', '-1', '<p>The...', '', '2', '', 'C', false, true, '1', '', '', 'Banglore', 'karnatak', '', '1', '1', '1', 'IT', false)\n#2 /var/www/html/opencats/modules/joborders/JobOrdersUI.php(123): JobOrdersUI->onAdd()\n#3 /var/www/html/opencats/lib/ModuleUtility.php(79): JobOrdersUI->handleRequest()\n#4 /var/www/html/opencats/index.php(272): ModuleUtility::loadModule('joborders')\n#5 {main}\n thrown in /var/www/html/opencats/lib/Contacts.php on line 788, referer: http://localhost/opencats/index.php?m=joborders&a=add&jobOrderID=2&typeOfAdd=new
完整的课程可以在这里找到
https://github.com/opencats/OpenCATS/blob/master/lib/Contacts.php