有谁可以告诉我为什么忽略SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Stack trace:
d3_json@http://d3js.org/d3.v3.js:9488:12
respond@http://d3js.org/d3.v3.js:1939:20
?
我正在尝试传递一个参数并且始终获得$Role
值,但是,当我调用该方法时,null
显示var_dump
为2。
当我在$Role
内使用var_dump时,getListFromDB
被设置为null。
方法getListFromDB()
$Role
如何调用该方法:
function getListFromDB($tableName, $orderBy = 'Description', $where = null, $Role = null) {
DO_Common::debugLevel(0);
if (empty($tableName) || empty($orderBy))
throw new Exception("tableName and orderBy cannot be left empty");
var_dump($Role);
if (!empty($Role))
{
echo "here";
if ($Role === 2)
{
if ($tableName == 'AssetTypes')
{
$params = array('tableName' => 'AssetTypes',
'orderBy' => $orderBy,
'whereAdd' => 'Restricted = 1');
}
var_dump($params);
}
else
{
$params = array('tableName' => $tableName,
'orderBy' => $orderBy);
var_dump($params);
}
}
else
{
$params = array('tableName' => $tableName,
'orderBy' => $orderBy);
//var_dump($params);
}
if (!empty($where) && $table != 'AssetTypes') {
if (strpos(strtolower($where), 'flag') === false)
$where .= " AND Flag != " . fDELETED;
$params += array('whereAdd' => $where);
}
return DO_Common::toAssocArray($params);
}
我在这里缺少什么?
答案 0 :(得分:1)
您应该将其称为第四个参数,如下所示:
getListFromDB("tablename", "some fancy description", "here", $Role);
我明白了......
答案 1 :(得分:1)
$Role
是函数的第四个参数,但是你将它作为第二个参数发送:
$AssetTypesOptions = getListFromDB('AssetTypes', 'Description', null, $Role);