How can I Insert JSON object into Postgres using Java preparedStatement?

This behaviour is quite annoying since JSON strings are accepted without problems when used as literal strings in SQL commands. There is a already an issue for this in the postgres driver Github repository (even if the problem seems the be the serverside processing). Besides using a cast (see answer of @a_horse_with_no_name) in the sql … Read more

Using fetch_assoc on prepared statements

That’s because fetch_assoc is not part of a mysqli_stmt object. fetch_assoc belongs to the mysqli_result class. You can use mysqli_stmt::get_result to first get a result object and then call fetch_assoc: $selectUser = $db->prepare(“SELECT `id`,`password`,`salt` FROM `users` WHERE `username`=?”); $selectUser->bind_param(‘s’, $username); $selectUser->execute(); $result = $selectUser->get_result(); $assoc = $result->fetch_assoc(); Alternatively, you can use bind_result to bind the … Read more

Retrieve (or simulate) full query from PDO prepared statement

I believe this is mentioned in the original question that was reference in this one. However there is actually supposed to be a method for retrieving this data. PDOStatement::debugDumpParams However it isn’t currently working as documented. There is a bug report and patch submitted for it here http://bugs.php.net/bug.php?id=52384 in case anyone is interested in voting … Read more

In SQLite, do prepared statements really improve performance?

Prepared statements improve performance by caching the execution plan for a query after the query optimizer has found the best plan. If the query you’re using doesn’t have a complicated plan (such as simple selects/inserts with no joins), then prepared statements won’t give you a big improvement since the optimizer will quickly find the best … Read more

MySQLi prepared statements with IN operator [duplicate]

I’ve recently found the solution for my question. Maybe it’s not the best way to do it, but it works nice! Prove me wrong:) <?php $lastnames = array(‘braun’, ‘piorkowski’, ‘mason’, ‘nash’); $arParams = array(); foreach($lastnames as $key => $value) //recreate an array with parameters explicitly passing every parameter by reference $arParams[] = &$lastnames[$key]; $count_params = … Read more