【发布时间】:2021-05-06 03:14:14
【问题描述】:
我正在将应用程序从 PHP 5 转换为 PHP 7。
Before if $values=null 那么 $values after 的值为 null 或空数组。现在似乎成功了 [0=>空]
发生了什么变化?
if(!is_array($values)) {
$values = array($values);
}
/**
* Search for Imaging group report data by sysi code. Optionally
* specify a Banner username to narrow the search.
*
* @param Mixed $sysiCodes
* @param String $username
*/
public function searchBySysiCode($sysiCodes, $username = '%', $sort = 'user')
{
$imagingModuleDataAccess = new ImagingModuleDataAccess();
$imagingGroupDataAccess = new ImagingGroupDataAccess();
$op = '';
/* Retreive modules and build a search string based on the
specified sysi codes. This is required to ensure we exclude
"private" sysi codes and groups that cannot be requested
for access. */
$module = null;
if(is_array($sysiCodes))
{
foreach($sysiCodes as $sysiCode)
{
$module = $imagingModuleDataAccess->searchBySysiCode($sysiCode)->first();
if($module != null)
{
$searchString .= $op . $imagingGroupDataAccess->getGroupMapSearchString($module);
}
$op = ' or ';
}
}
else
{
$module = $imagingModuleDataAccess->searchBySysiCode($sysiCodes)->first();
if($module != null)
{
$searchString = $imagingGroupDataAccess->getGroupMapSearchString($module);
}
}
$searchString = " and ( $searchString ) ";
// Add the username if specified.
if($username != null && $username != '%')
{
$searchString .= ' and ae_login.usrnam like upper(?) ';
$values = $username;
}
// Add sorting option.
switch ($sort)
{
case 'user':
$searchString .= ' order by ae_login.usrnam, ae_als.aliasname ';
break;
case 'group':
default:
$searchString .= ' order by ae_als.aliasname, ae_login.usrnam ';
break;
}
return $this->search($searchString, $values);
}
/**
* Function used to access underlying datastore handle
*
* @param string $searchString sql where clause for search
* @param array $values bind values for sql
* @return mixed return type based on RETURNTYPE code
*/
protected function search($searchString, $values)
{
$return = '';
$sql = "select distinct
ae_login.usrnam,
ae_als.aliasid,
ae_als.aliasname,
ae_als.aliasdesc
from
otgmgr.ae_als,
otgmgr.ae_login,
otgmgr.ae_amap
where
1 = 1
and ae_amap.usrid = ae_login.usrid
and ae_als.aliasid = ae_amap.aliasid
$searchString ";
try
{
$return = $this->retrieve($sql, $values);
}
catch(Exception $e)
{
throw $e;
}
return $return;
}
protected function retrieve($sql, $values=array())
{
// The result set to return.
$return = '';
/* Doctrine DBAL */
if(!is_array($values)) {
$values = array($values);
}
$stmt = $this->dataSource->executeQuery($sql, $values);
// Determine what type of result to return.
if ($this->returnType == RETURNTYPE_RAW) {
$return = $stmt;
} else if ($this->returnType == RETURNTYPE_ARRAY) {
$return = $this->getArray($stmt);
} else if ($this->returnType == RETURNTYPE_ASSOC) {
$return = $this->getAssoc($stmt);
} else if ($this->returnType == RETURNTYPE_ITERATOR) {
$return = $this->getIterator($this->getArray($stmt));
} else {
throw new Exception('Invalid returnType ' . $this->returnType);
}
return $return;
}
【问题讨论】:
-
据我所知,行为没有改变。请参阅3v4l.org/qnvXI 设置后,您处理的方式可能发生了变化。这里有很多代码 - 突出显示问题区域。