Get query back from PDO prepared statement
Is there a way to retrieve the query that was used to generate a PDO Prepared statement object? ...
Is there a way to retrieve the query that was used to generate a PDO Prepared statement object? ...
hi, I have table where I need to select MAX(SUM(total)) of a periods total. SELECT SUM(P.amount) as total FROM bank P WHERE P.ReceivedDate >= '2008-07-28' AND P.ReceivedDate <= '2008-08-31'; SELECT SUM(P.amount) as total FROM bank P WHERE P.ReceivedDate >= '2008-09-01' AND P.ReceivedDate <= '2008-09-28'; SELECT SUM(P.amount) as total...
Someone asked me to design a database and implement it using MySQL. Additionally, I am also asked to write PHP scripts so that one can do some "simple" data analysis with the data inside MySQL. It is not very complicated. It is like a school database and I will have to write programs that will retrieve all the classes that a student has ...
I need to create a dump file such that when i execute it, i have no depency issues tables run before queries parent tables before child tables etc no failed insert due to foreign key failures ...
Hello, I am running a query to populate a dropdown menu, however the column I am using a list of company names, this means that the company name is often repeated, is there way to only get each repeated value only once? So for instance if I have in the table something like, Company 1 Company 1 Company 2 Company 3 Company 4 Company 4 ...
hi I have just moved a php site to a new server. One of my queries is failing with Data truncated for column 'xxx' ar row 1 message. I checked that this field is float (10,6) type. And the values I provided white updating are not of exactly float(10,6) format and they vary .. like sometimes I put 0 only, or 54.56666 only .. so any idea ...
I have a table/grid system with a 7 days along the top and the various types of data down the side, now for each type of data against a particular day there's a plus and minus sign so the user can increase or decrease the data occurrences. Now given that there's plenty of data types as well as 7 (for each day) values for each type, what'...
What I'm trying to do is, replacing symbols that would be changed start the string then the last symbol that would close the string - changing both of them into a link then it will be stored into the database, it's something like Wikipedia. I want to have something like this when someone types in the textarea: "This woman was killed by...
I am storing network share paths in my table in MySQL. but some entries got corrupted, i.e they dont have any backslashes in between. Path is like a big word. I wrote a small script in PHP to update these paths to try and add slashes. It does not give me any error when I run it but the results are not getting updated in the table. Curr...
Can anyone recommend the best practice for storing general site preferences? For example, the default page title if the script doesn't set one, or the number of featured items to display in a content box, or a list of thumbnail sizes that the system should make when a picture is uploaded. Centralizing these values has the obvious benefit...
I'd like to have access to $lastID when calling raw Is there a way to do this? public static $lastID; public function raw($sql){ if(!$result = mysql_query($sql)){ throw new Exception("Could not perform query: " .mysql_error()); } self::$lastID = mysql_insert_id(); return($result); } Edit: it is a class mem...
I'm trying to write a sql function to do something like: SELECT person.id, person.phonenumber FROM person INNER JOIN activity ON person.id = activity.personid WHERE MAX(activity.activitydate) < DATE_SUB(CURDATE(), INTERAVAL 180 DAY); Each time a person is contacted, we create an activity record for them with notes and...
Part of the code I'm using is: $password = MD5($password); $account_created = date("Y-m-d H-i-s"); db_insert("users","user_id,username,password,account_created,registration_ip","ENCRYPT('$_POST[username] $account_created'),'$_POST[username]',MD5('$_POST[password]'),'$account_created','$_SERVER[REMOTE_ADDR]'"); ...
Hello! I have a for loop which actually displays a product name and several buttons like: Edit, Update , Cancel For each product i am displaying , it will have its own set of Edir, Update, and Cancel button as below. Paint Edit Update Cancel I want to loop through the buttons so that for each category, I can perform a d...
How do I create a view only if it doesn't exist. If it does exist, I want to drop the view and redefine it. I also want no warnings or errors. ...
Considering this MySQL query: SELECT someColumns FROM someTable WHERE someColumn IN ( value1, value2, value3 ) ... how can I guarantee that the rowset comes out ordered in the exact order of the values given to the IN () clause? I presume this is not guaranteed without giving it an ORDER BY clause, is it? PS.: The values to the...
If you want the relevance and also the results to be sorted by relevance the common format of a FULLTEXT query is: SELECT name, MATCH(name) AGAINST('Bob') AS relevance FROM users WHERE MATCH(name) AGAINST('Bob') As a developer I always like to make my code DRY(don't repeat yourself). Is there any reason not to write the query as: SEL...
SELECT Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total FROM question WHERE COUNT(*) DESC GROUP BY UName doesn't work :( ...
Hi, can someone tell me how to create a nice small tooltip like ajax pop-up ? the situation is like this, I am pulling the $row->title from the db, and then I presented it as a link like this <?php foreach($task->result() as $row): ?> <tr> <td><a href=#><?php echo $row->title; ?></a></td> </tr> <?php endforeach; ?> wh...
Hello, I'm having a problem getting a query to work, which I think should work. It's in the form SELECT DISTINCT a, b, c FROM t1 WHERE NOT IN ( SELECT DISTINCT a,b,c FROM t2 ) AS alias But mysql chokes where "IN (" starts. Does mysql support this syntax? If not, how can I go about getting these results? I want to find distinct tuples ...