I want to execute raw SQL using Doctrine 2 I need to truncate the database tables and initialize tables with default test data. Answer I found out the answer is probably: A NativeQuery lets you execute native SQL, mapping the results according to your specifications. Such a specification that describes how an SQL result set is mapped to a Doctrine
Tag: sql
Help Reading Binary Image Data from SQL Server into PHP
I cannot seem to figure out a way to read binary data from SQL server into PHP. I am working on a project where I need to be able to store the image directly in the SQL table, not on the file system. Currently, I have been using a query like this one: INSERT INTO myTable(Document) SELECT * FROM OPENROWSET(BULK
Duplicate a record in MySQL
I have a table and I want to duplicate specific rows in the table. I know this is not the best way to do things but we are looking for a quick solution. Here’s something harder than I initially thought, all I need to do is copy an entire record to a new record in an auto-increment table in MySql
mssql_bind empty string converting to NULL
I am currently using SQL Server 2000 Stored Procedures with PHP. Following the PHP doc, I use mssql_bind to assign value of parameters and then execute the Stored Procedure. The problem is that I got this bug which prevents me to bind empty strings to parameters (they are converted to NULL when the Stored Proc gets called) I dont’t want
MySQL query to extract first word from a field
I would like to run a query that returns the first word only from a particular field, this field has multiple words separated by spaces, I assume I may need to carry out some regex work to accomplish this? I know how to do this using a few ways in PHP but this would best be carried out on the
Limit a MySQL query to an even number of results
I have a bit of PHP code which I need to return an even number of results from a MySQL database. I’m using the mysqli extension to execute my query. My code is approximately this at the moment: //…
MySQL Prepared statements with a variable size variable list
How would you write a prepared MySQL statement in PHP that takes a differing number of arguments each time? An example such query is: The IN clause will have a different number of ids each time it is run. I have two possible solutions in my mind but want to see if there is a better way. Possible Solution 1