Knowledge Base

January 31, 2008

Display textarea content with line breaks in html page

Filed under: Technical — Tags: , , , — rkutti @ 12:21 pm

Let us see how javascript, php, and ruby display the content of textarea with line breaks

Javascript:

document.getElemnetById(‘textareacontent’).value.replace(/\n/g,’<br>’);

PHP:

preg_replace(“/\n/”,”<br>”,$_REQUEST['t1']);

Ruby:

(teaxtareacontent).gsub(/\n/,”<br>”)

January 29, 2008

PHP Singleton Object

Filed under: Technical — Tags: , — rkutti @ 1:58 pm

The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.

Here is an example, that demonstrates this singleton pattern: (more…)

January 23, 2008

Take the dump of database from the console

Filed under: Technical — Tags: , , — rkutti @ 8:09 am

To take dump of whole database:
$ mysqldump -u <username> -p <databasename> > <filename>.sql

To take dump of the (only)structure of the database
$ mysqldump -u <username> -p <databasename> -d > <filename>.sql

To take dump of the (only)data of the database
$ mysqldump -u <username> -p <databasename> -t > <filename>.sql

To take dump of the database with complete insert statement
$ mysqldump -u <username> -p <databasename> -c > <filename>.sql

January 8, 2008

How to create database using mysql commands

Filed under: Technical — Tags: — rkutti @ 9:39 am

To create database from command prompt. Login to mysql as root user.
To login into mysql prompt in linux machine.
Type the following command in the console

$ mysql -u <username> -p<password>

After entering the mysql prompt follow these steps to create a database
and load the database with sql file.

A CREATE DATABASE statement to create a database.
> create database <databasename>;

A GRANT statement to grant privileges to database.
> grant all on <databasename>.* to <username>@localhost identified by ‘<password>’;

A FLUSH PRIVILEGES statement to tell the server to reload the grant.
> flush privileges;

A USE statement to tell the server to use the given database for further operations.
> use <databasename>;

A SOURCE statement to tell server to load the given sql file in the database.
> source <filename.sql>

Blog at WordPress.com.