Skip to content
Advertisement

Tag: mysql

Tracking the views of a given row

I have a site where the users can view quite a large number of posts. Every time this is done I run a query similar to UPDATE table SET views=views+1 WHERE id = ?. However, there are a number of disadvantages to this approach: There is no way of tracking when the pageviews occur – they are simply incremented. Updating

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

MySQL: Join query across multiple databases located on different servers

In SQL Server there is a way to join tables from multiple sql servers by using link tables. I wonder whether is it possible to do the same? I am using PHP, does PHP provides this kind of facilities? Answer It isn’t necessarily easy, nor pretty, but this article gives some solutions to your problem: http://www.linux.com/archive/feature/52390 UPDATE Since the link

PDO looping through and printing fetchAll

I’m having trouble getting my data from fetchAll to print selectively. In normal mysql I do it this way: In PDO, I’m having trouble. I bound the params, then I’m saving the fetched data into $rs like above, with the purpose of looping through it the same way.. Now comes the trouble part. What do I do PDO-wise to get

Mysql transactions within transactions

In a PHP script working with a mysql database, I recently had the need to use a transaction at a point that happened to be inside another transaction. All my tests seem to indicate this is working out fine, but I can’t find any documentation on this usage. I want to be sure – are transactions within transactions valid in

Invoking a PHP script from a MySQL trigger

Is there any way how to invoke a PHP page / function when a record is inserted to a MySQL database table? We don’t have control over the record insertion procedure. Is there a trigger mechanism which can call a PHP script back? Answer The trigger is executed on the MySQL server, not on the PHP one (even if those

How do I set the selected item in a drop down box

Is there any way to set the selected item in a drop down box using the following ‘type’ code?