joomla database methods
Asked Answered
H

1

3

How do I use in case of Joomla the mysqli bind_param

how would this example should be declared using joomla Database methods?

...
$statement->bind_param('s', $like);
$statement->execute();
Horacehoracio answered 4/4, 2013 at 13:4 Comment(3)
It seems that Joomla do not have support for mysqli_stmt class. github.com/joomla/joomla-cms/tree/master/libraries/joomla/…Wither
thank you for your feedback, I do not see as well any reference in the source. it seems like I have to use another workaroundHoracehoracio
For anyone on Joomla4 or higher, there are prepared statements. https://mcmap.net/q/1513018/-how-to-use-prepared-statements-in-joomla , https://mcmap.net/q/1633495/-how-to-use-prepare-statements-bind-values-in-a-query-in-joomla-3 , joomla.stackexchange.com/q/12119/12352Redd
S
1

In Joomla! 3.1, PDO/Sqlite and PDO/Oracle are supporting prepared statements, others are not implemented yet.

Given using a 'preparable' connection, it would work this way:

$db    = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('...')->where('...');

$query->bind(':s', $like);

$db->setQuery($query);

$records = $db->loadObjectList();
Salpingitis answered 1/6, 2013 at 21:50 Comment(2)
Note that in 2016 they added mysqli and mysql prepared statement support.Hofmann
You must be kidding. I am talking about Joomla support. joomla.stackexchange.com/a/22712/12352Redd

© 2022 - 2024 — McMap. All rights reserved.