Hello. I tried to write code to get 'Maps' by some parameter with single function.
But faced with an almost insurmountable obstacle.
Not works:
Not works:
Only this function works:
How to use '?' after 'WHERE' ?
This is bug or what ?
But faced with an almost insurmountable obstacle.
Not works:
PHP:
public static function getMapsCountByParam( $param, $val )
{
$db = \XF::db();
$map = $db->fetchOne("SELECT COUNT(id) FROM maplist WHERE ? = ?",["user_id",$val]);
return $map;
}
...
getMapsCountByParam("user_id",$visitor->user_id);
Not works:
PHP:
public static function getMapsCountByParam( $param, $val )
{
$db = \XF::db();
$map = $db->fetchOne("SELECT COUNT(id) FROM maplist WHERE ? = ?",[$param,$val]);
return $map;
}
...
getMapsCountByParam("user_id",$visitor->user_id);
Only this function works:
PHP:
public static function getMapsCountByParam( $param, $val )
{
$db = \XF::db();
$map = $db->fetchOne("SELECT COUNT(id) FROM maplist WHERE user_id = ?",[$val]);
return $map;
}
...
getMapsCountByParam("user_id",$visitor->user_id);
How to use '?' after 'WHERE' ?
This is bug or what ?