Practical Web Programming

Tuesday, April 09, 2013

Backup table data including indexes with SQL

Here's a short and sweet way to backup table data including all the indexes using simple SQL syntaxes.

Create an exact copy of the table you want to backup:

CREATE TABLE new_table_name LIKE old_table_name;

Copy the data from the old table to the new one:

INSERT new_table_name SELECT * FROM old_table_name;

Wednesday, April 03, 2013

JQuery: How to prevent click event handler from being bound multiple times

A simple trick is to add a class to the element and bound only if the element don't have that class yet.

<script type="text/javascript">
        .bind('click', onClick);
    function onClick() {
        alert('You clicked me!');

Recent Post