prepared-statement

MySql: Will using Prepared statements to call a stored procedure be any faster with .NET/Connector?

Deadly 提交于 2019-12-01 11:28:15
I've been reading a bit about Prepared statements with MySql, and the .NET/Connector does support them. What I'm wondering, is if I use a prepared statement to call the same stored procedure thousands of times, is that any faster or better performance than not using prepared statements to do so (since the stored procedure should really be compiled already)? Eg: var mySqlCmd = new MySqlCommand(con, "call sp_someProcedure(@param1, @param2);"); mySqlCmd.Prepare(); mySqlCmd.Parameters.AddWithValue("@param1", ""); mySqlCmd.Parameters.AddWithValue("@param2", ""); for (int i = 0; i < 1000; i++) {

PDO prepared statements to store html content

ぐ巨炮叔叔 提交于 2019-12-01 11:19:40
I'm looking for a way to handle HTML content within prepared statements. My application provides a basic WYSIWYG Editor and after the user is saving the content my script stores HTML-Data in an sqlite database. But if i'am using a prepared statement my HTML gets -naturally- escaped. This is what i've so far: try { /* Create databases and open connections */ $dbh = new PDO( 'sqlite:db/coaching.sqlite' ); /* Set Error Mode for Exception Handling */ $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); /* Prepare SQL Statement */ $query = $dbh->prepare( "UPDATE Content SET Value=:value

Don't use prepared statements in Laravel Eloquent ORM?

ε祈祈猫儿з 提交于 2019-12-01 11:09:53
Can I have Eloquent ORM run a query without using prepared statements? Or do I have to use whereRaw() ? I need to use a raw query because I'm trying to interact with InfiniDB, which lacks support for prepared statements from PHP. At any rate, all queries will be using internally generated data, not user input so it should not be a security issue. For anything other than SELECT you can use unprepared() DB::unprepared($sql); For an unprepared SELECT you can use plain PDO query() by getting access to active PDO connection through getPdo() $pdo = DB::getPdo(); $query = $pdo->query($sql); $result =

How to use prepared statement

和自甴很熟 提交于 2019-12-01 10:44:44
Someone has suggested to use prepared statement but I don't know how to use it. What changes do I have to do in my code? try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("\n Driver loaded"); Connection con = DriverManager.getConnection("jdbc:odbc:wanisamajDB"); Statement stmt = con.createStatement(); System.out.println("statement is created"); // System.out.println(Integer.parseInt(cbregn.getSelectedItem().toString())); String qry = " UPDATE Registration1 SET RegistrationNo = '"+cbregn.getSelectedItem()+"',SeniorPerson = '"+cbnm.getSelectedItem()+"', NativePlace = '"

PHP: Mysqli prepared statement with “select *”

情到浓时终转凉″ 提交于 2019-12-01 10:31:11
问题 This is how I presently fetch from the DB: if ($stmt = $mysqli->prepare ( "SELECT fname,lname from $table_name where cno >=? LIMIT 50" )) { $stmt->bind_param ( "i", $cno); $stmt->execute (); $stmt->bind_result ($fname,$lname); $arrayUsers = array(); while ($stmt->fetch()) { if (isset ($fname)) { $arrayUsers[] = array( "fname" => $fname, "lname" => $lname); } } $stmt->close (); } $mysqli->close (); and it works great. But if I change my select to SELECT * from ... my bindings fail. Does that

Get the last entries using GROUP BY

大城市里の小女人 提交于 2019-12-01 10:30:06
I'm having problem with GROUP BY. It returns the first entry it could find, but I would like it to return the last entry. Is that possible? Here is my query (prepared query): SELECT stamp_user, stamp_date, stamp_type FROM rws_stamps WHERE stamp_date >= ? GROUP BY stamp_user ORDER BY stamp_date DESC My table looks like this: What I want it to return is row 7 and 3, but i get 1 and 2. Try: SELECT stamp_user, max(stamp_date), stamp_type FROM rws_stamps WHERE stamp_date >= ? GROUP BY stamp_user, stamp_type 来源: https://stackoverflow.com/questions/3811750/get-the-last-entries-using-group-by

Don't use prepared statements in Laravel Eloquent ORM?

為{幸葍}努か 提交于 2019-12-01 10:22:17
问题 Can I have Eloquent ORM run a query without using prepared statements? Or do I have to use whereRaw() ? I need to use a raw query because I'm trying to interact with InfiniDB, which lacks support for prepared statements from PHP. At any rate, all queries will be using internally generated data, not user input so it should not be a security issue. 回答1: For anything other than SELECT you can use unprepared() DB::unprepared($sql); For an unprepared SELECT you can use plain PDO query() by getting

PDO prepared statements to store html content

蓝咒 提交于 2019-12-01 09:29:27
问题 I'm looking for a way to handle HTML content within prepared statements. My application provides a basic WYSIWYG Editor and after the user is saving the content my script stores HTML-Data in an sqlite database. But if i'am using a prepared statement my HTML gets -naturally- escaped. This is what i've so far: try { /* Create databases and open connections */ $dbh = new PDO( 'sqlite:db/coaching.sqlite' ); /* Set Error Mode for Exception Handling */ $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO:

CREATE DATABASE query using java jdbc and prepared statement returns syntax error

匆匆过客 提交于 2019-12-01 09:27:59
I am trying to get Java to create a database using JDBC but I get a syntax error, despite the query being correct. If I write the name of a database into the code explicitly, for example, it works fine. Here's my code: package mysql_manipulator; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class Create { private static final String driver = "com.mysql.jdbc.Driver", url = "jdbc:mysql://localhost", username = "dylan", password = "******"; private String databaseName; public Create (){ this.databaseName = null; } public String

How to use prepared statement

时光总嘲笑我的痴心妄想 提交于 2019-12-01 09:06:24
问题 Someone has suggested to use prepared statement but I don't know how to use it. What changes do I have to do in my code? try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("\n Driver loaded"); Connection con = DriverManager.getConnection("jdbc:odbc:wanisamajDB"); Statement stmt = con.createStatement(); System.out.println("statement is created"); // System.out.println(Integer.parseInt(cbregn.getSelectedItem().toString())); String qry = " UPDATE Registration1 SET