joomla-cms
joomla-cms copied to clipboard
[4.2] Missing ParameterType::DOUBLE in case of prepared statements
Steps to reproduce the issue
Use the ParameterType::DOUBLE
Expected result
No error message
Actual result
Error message: Undefined class constant 'DOUBLE'
System information (as much as possible)
J4.x
Additional comments
Honestly I don't know if this is really a bug, but a conscious choice of Joomla design in the past.
It's a kinda conscious choice. The parameter types are a way for us to backport PDO's parameter types into the other languages. Double isn't one of these types (the 5 we have are a mapping to the non-php 7.2 param types here https://www.php.net/manual/en/pdo.constants.php) so we've not done anything special for it
@wilsonge
1) Joomla has defined the following parameters:
JOOMLA\libraries\vendor\joomla\database\src\Sqlsrv\SqlsrvStatement.php
protected $parameterTypeMapping = [ ParameterType::BOOLEAN => ParameterType::BOOLEAN, ParameterType::INTEGER => ParameterType::INTEGER, ParameterType::LARGE_OBJECT => ParameterType::LARGE_OBJECT, ParameterType::NULL => ParameterType::NULL, ParameterType::STRING => ParameterType::STRING, ];
2) I compare the Joomla parameters with the following:
https://www.php.net/manual/en/mysqli-stmt.bind-param.php
i corresponding variable has type integer d corresponding variable has type double s corresponding variable has type string b corresponding variable is a blob and will be sent in packets
3) That's why I started this issue. But I may be seeing this wrong.
you do realise that the first file you reference is for sql server?
This is an example of what I mean.
The ParameterType::DOUBLE is not available.
$test = (float) $value; // e.g. $value = 2.2311
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__example'))
->where($db->quoteName('test') . ' = :test')
->bind(':test', $test, ParameterType::DOUBLE);
$db->setQuery($query);
$db->execute();
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38730.
Closed