Advertisement

  • Simple on the fly loop on solarie

    How to see list of files of a directory and executing required commands on the file.
    I have just used a for loop. there may be other options. this is just one option...
    and it is sometimes use full. and do the same for linux

    for file in $(ls HLRProvFailed)
    do echo $file;
    cat HLRProvFailed/$file |wc -l;
    done;

    more
  • MySQL Databases Backup Using PHP

    Technique

    1. Execute a database backup query from PHP file.
    2. Run mysqldump using system() function.

    1.

    include 'config.php';
    include 'opendb.php';

    $tableName = 'mypet';
    $backupFile = 'backup/mypet.sql';
    $query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
    $result = mysql_query($query);


    include 'closedb.php';
    ?>

    To restore the backup you just need to run LOAD DATA INFILE query like this :

    include 'config.php';
    include 'opendb.php';

    $tableName = 'mypet';
    $backupFile = 'mypet.sql';
    $query = "LOAD DATA INFILE 'backupFile' INTO TABLE $tableName";
    $result = mysql_query($query);


    include 'closedb.php';
    ?>

    The system() function is used to execute an external program. Because MySQL already have built in tool for creating MySQL database backup (mysqldump) let's use it from our PHP script

    2.

    include 'config.php';
    include 'opendb.php';

    $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
    $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
    system($command);

    include 'closedb.php';
    ?>

    more
  • Online Database backup in mysql

    You have a mysql database. now you want to have a backup database which will contain all of the backup of your live database, that means all the live transection will be replicated on your backup database.

    For business point of view this is very important!
    Bellow are the some easy steps to made online backup database.


    For example you have two database on different machine with different ip, namely
    master 10.10.10.100
    slave 10.10.10.111


    ON MASTER:


    1. create an user rep
    2. mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.10.10.111' IDENTIFIED BY 're
    plpass';
    3.Setting the Replication Master Configuration (my.cnf or my.ini file)
    [mysqld]
    log-bin=mysql-bin
    server-id=1

    ON SLAVE

    4.Setting the Replication Slave Configuration
    [mysqld]
    server-id=2

    again ON MASTER
    5. Obtaining the Master Replication Information
    mysql> FLUSH TABLES WITH READ LOCK;
    mysql > SHOW MASTER STATUS;

    here you will find like following info
    MASTER_LOG_FILE='mysql-bin.000006',
    MASTER_LOG_POS=1123077;


    6. Creating a Data Snapshot Using mysqldump
    mysql> FLUSH TABLES WITH READ LOCK;

    shell> mysqldump --all-databases --lock-all-tables >dbdump.db
    "C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump.exe" -u root -pmypassword* --opt swa > swa.sql

    ON SLAVE

    7. Create same database with same name and up the damped file.

    8.Setting Up Replication with New Master and Slaves
    Execute the CHANGE MASTER command to set the master replication server configuration

    CHANGE MASTER TO
    MASTER_HOST='10.10.10.100',
    MASTER_USER='repl',
    MASTER_PASSWORD='replpass',
    MASTER_LOG_FILE='mysql-bin.000006',
    MASTER_LOG_POS=1123077;

    9.mysql> START SLAVE;


    10. be happy :-)


    please leave your comment....


    More info in bangla

    More information

    more
  • How to write PHP code in Joomla 1.5

    I found some people is being searching for the solution " how to write PHP code in Joomla".

    Ans is pretty simple:

    1. Download the pulgin from here
    2. Upload it using Install option of Joomla 1.5
    3. Dont forget to enable it. and
    4. finally, write the code like

    {php}echo "Welcome to expertsolver!!"; {/php}


    thats it.

    more
  • Joomla Tutorial

    Joomla is a web application that makes it easy for groups of people to build a website.

    In fact Joomla is so easy to use that it is a good tool for even a single individual to use when building a web site.

    Applications like Joomla are called "Content Management Systems" (CMS). You can read more about CMS at Wikipedia .

    Two of the other more popular CMS applications are Plone and Drupal . Joomla is probably the easiest to use and best supported of the more popular CMS applications.

    If you have a website and want to be able to change the content of that site easily and / or frequently, Joomla could be a good choice for you. With Joomla, you can log in to the site and edit the site directly in your browser. You can add new pages and these pages will automatically be added to all navigation.

    If you want more than one person to be able to edit the site you can give logins to other people, and set permissions as to whether they can post new content or just submit it for review by you.

    If you have a website and want to be able to change the content of that site easily and / or frequently, Joomla could be a good choice for you. With Joomla, you can log in to the site and edit the site directly in your browser. You can add new pages and these pages will automatically be added to all navigation.

    If you want more than one person to be able to edit the site you can give logins to other people, and set permissions as to whether they can post new content or just submit it for review by you.



    Download a very good tutorial

    more
  • Trigger in mysql easy steps

    Today i will show you how to write your first trigger in mysql5. its very easy just follow the bellows steps:

    i am considering you have a table named employee in your mysql database.

    Now -

    C:\>mysql -u root -p

    mysql> SELECT * FROM Employee;

    +-----+---------+----------+-------------------+--------+-------+
    | Eid | Ename | City | Designation | Salary | Perks |
    +-----+---------+----------+-------------------+--------+-------+
    | 1 | Rahul | Delhi | Manager | 10300 | 853 |
    | 2 | Gaurav | Mumbai | Assistant Manager | 10300 | 853 |
    | 3 | Chandan | Banglore | Team Leader | 15450 | 999 |
    | 5 | Tapan | Pune | Developer | 20600 | 1111 |
    | 6 | Amar | Chennai | Developer | 16000 | 1124 |
    | 7 | Santosh | Delhi | Designer | 10000 | 865 |
    | 8 | Suman | Pune | Web Designer | 20000 | 658 |
    +-----+---------+----------+-------------------+--------+-------+
    7 rows in set (0.00 sec)
    mysql> delimiter //
    mysql> CREATE TRIGGER ins_trig BEFORE INSERT ON Emp
    -> FOR EACH ROW
    -> BEGIN
    -> UPDATE Employee SET Salary=Salary-300 WHERE Perks>500;
    -> END;

    -> //
    Query OK, 0 rows affected (0.01 sec)
    mysql> delimiter ;
    mysql> INSERT INTO Emp VALUES(9,'Rajesh','Delhi','Developer',15000,658);
    Query OK, 1 row affected (0.05 sec)
    mysql> SELECT * FROM Employee;
    +-----+---------+----------+-------------------+--------+-------+
    | Eid | Ename | City | Designation | Salary | Perks |
    +-----+---------+----------+-------------------+--------+-------+
    | 1 | Rahul | Delhi | Manager | 10000 | 853 |
    | 2 | Gaurav | Mumbai | Assistant Manager | 10000 | 853 |
    | 3 | Chandan | Banglore | Team Leader | 15150 | 999 |
    | 5 | Tapan | Pune | Developer | 20300 | 1111 |
    | 6 | Amar | Chennai | Developer | 15700 | 1124 |
    | 7 | Santosh | Delhi | Designer | 9700 | 865 |
    | 8 | Suman | Pune | Web Designer | 19700 | 658 |
    +-----+---------+----------+-------------------+--------+-------+
    7 rows in set (0.00 sec)

    In the following example we are modifying the salary of Employee table before updating the record of the same table. Example :

    mysql> delimiter //
    mysql> CREATE TRIGGER updtrigger BEFORE UPDATE ON Employee
    -> FOR EACH ROW
    -> BEGIN
    -> IF NEW.Salary<=500 THEN -> SET NEW.Salary=10000;
    -> ELSEIF NEW.Salary>500 THEN
    -> SET NEW.Salary=15000;
    -> END IF;
    -> END

    -> //
    Query OK, 0 rows affected (0.01 sec)
    mysql> delimiter ;
    mysql> UPDATE Employee
    -> SET Salary=500;
    Query OK, 5 rows affected (0.04 sec)
    Rows matched: 7 Changed: 5 Warnings: 0
    mysql> SELECT * FROM Employee;
    +-----+---------+----------+-------------------+--------+-------+
    | Eid | Ename | City | Designation | Salary | Perks |
    +-----+---------+----------+-------------------+--------+-------+
    | 1 | Rahul | Delhi | Manager | 10000 | 853 |
    | 2 | Gaurav | Mumbai | Assistant Manager | 10000 | 853 |
    | 3 | Chandan | Banglore | Team Leader | 10000 | 999 |
    | 5 | Tapan | Pune | Developer | 10000 | 1111 |
    | 6 | Amar | Chennai | Developer | 10000 | 1124 |
    | 7 | Santosh | Delhi | Designer | 10000 | 865 |
    | 8 | Suman | Pune | Web Designer | 10000 | 658 |
    +-----+---------+----------+-------------------+--------+-------+
    7 rows in set (0.00 sec)
    mysql> UPDATE Employee
    -> SET Salary=1500;
    Query OK, 7 rows affected (0.03 sec)
    Rows matched: 7 Changed: 7 Warnings: 0
    mysql> SELECT * FROM Employee;
    +-----+---------+----------+-------------------+--------+-------+
    | Eid | Ename | City | Designation | Salary | Perks |
    +-----+---------+----------+-------------------+--------+-------+
    | 1 | Rahul | Delhi | Manager | 15000 | 853 |
    | 2 | Gaurav | Mumbai | Assistant Manager | 15000 | 853 |
    | 3 | Chandan | Banglore | Team Leader | 15000 | 999 |
    | 5 | Tapan | Pune | Developer | 15000 | 1111 |
    | 6 | Amar | Chennai | Developer | 15000 | 1124 |
    | 7 | Santosh | Delhi | Designer | 15000 | 865 |
    | 8 | Suman | Pune | Web Designer | 15000 | 658 |
    +-----+---------+----------+-------------------+--------+-------+
    7 rows in set (0.01 sec)

    enjoy :)

    now i little more about database trigger comparison:

    Which supports the most triggers, Microsoft SQL Server, Oracle or MySQL? How should that affect my decision in regards to choosing a database?

    Triggers are fairly new to MySQL and are, therefore, still in an early stage of development. There are a number of limitations you might find too restrictive if you rely heavily on triggers for your application. All three databases support row triggers before and after insert, update and delete statements. Oracle and Microsoft SQL Server also offer statement triggers.

    MySQL allows, at most, one trigger per table per event time and type -- a table can only have one BEFORE INSERT trigger, for example. Both Orable and SQL Server permit multiple triggers of each type on a table. The order in which they execute may not be defined.

    MySQL requires each of the six possible triggers to be defined separately. If you want to perform the exact same action on INSERT or on DELETE, you must define two separate triggers. Oracle and SQL Server allow trigger definitions to include multiple event types, such as BEFORE INSERT, DELETE

    MySQL does not permit dynamic SQL in a trigger, or in a stored procedure called by a trigger. There is no such restriction in Oracle.

    Both MySQL and Oracle attempt to prevent mutating table errors where, for example, a trigger attempts to modify the table which called it. MySQL and Oracle try to stop this by preventing such triggers from being created. It is still possible to create such errors, using cascading foreign keys or by other means. SQL Server allows for recursive triggers, and so must be coded carefully to prevent endless recursion.


    more

Custom Search

Featured Video

Photos