Monday, 19 December 2011

How to send array from action to template in symfony?


Suppose we have testArray given following:

$this->testArray = array('ashwani', 'bablu','cintu');
$myArray = $sf_data->getRaw('testArray');
print_r($myArray);

Output will be in template file:

Array
(
    [0] => 'ashwani'
    [1] => 'bablu'
    [3] => 'chintu'
)


Cheers!

Thursday, 15 December 2011

How to generate Module in symfony?

$ php symfony doctrine:generate-module frontend organizer EventOrganizer

this will generate template with tr td format.

OR

$ php symfony doctrine:generate-module  --with-show --non-verbose-templates frontend organizer EventOrganizer

this will generate template with echo $form format.




here organizer is a module name and EventOrganizer is table name defined in schema.yml


Cheers!

Thursday, 13 October 2011

How to find text recursively in file using linux commad?

Folks,

Please use the following command:

find <folderpath> -type f | xargs grep -l "131848637983654"

Here "131848637983654" has to find in <folderpath>

Cheers!

Monday, 3 October 2011

How to use symfony inbuild functions in non-symfony class in lib folder?

Dear,

$sfUser = sfContext::getInstance()->getUser();
$sfRequest = sfContext::getInstance()->getRequest();
$sfController = sfContext::getInstance()->getController();

$sfUser->setAttribute('abc','yes');
$sfRequest->setMethod();
$sfController->redirct('cart/list');


Cheers!

Thursday, 29 September 2011

How to automatically backup mysql database using cron?

Hi All,

Open crontab in linux server or window server and write the following line. this will backup database each mint.

$crontab -e

press enter and crontab will be opened and write following line:

* * * * * mysqldump -uroot -proot  ipay4me | gzip -9 > /var/www/archive/dbbackup/ipay4me.sql.gz


OR


$vim /var/www/archive/dumpdatabase

Write down following lines into that file:

#!/bin/bash
clear
mysqldump -uroot -hlocalhost -proot ipay4me | gzip -9 > /var/www/archive/dbbackup/ipay4me_$(date +"%d-%m-%Y-%H-%I-%S").sql.gz
exit 0


Set crontab:

50 11 * * * /var/www/archive/dumpdatabase /usr/bin/php Asia/Calcutta >/dev/null 2>&1

This cron will run daily at 11:50 PM



Cheers!

Tuesday, 27 September 2011

How to import a compressed mysql file .sql.gz using linux?

Hellos,

Please do the following to do the same.

zcat /newsites/urdutahzeeb/urdutahzeeb.net/dbbackup/urdujoom.sql.gz | mysql -u naughty -p urdujoom

Cheers!


Wednesday, 21 September 2011

How to change color on focus of input box using jquery?

Hi Dear,

<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
.focused {
    background: #abcdef;
}
</style>
<form name="focusForm" id="focusForm" method="POST" >
<table width="100%" cellspacing="2" cellpadding="2" >
    <tr>
        <td width="180">First Name: </td>
        <td><input type="text" name="txtFName" value="" /></td>
    </tr>
    <tr>
        <td>Last Name: </td>
        <td><input type="text" name="txtLName" value="" /></td>
    </tr>
    <tr>
        <td>Age: </td>
        <td><input type="text" name="txtAge" value="" /></td>
    </tr>
    <tr>
        <td>Occupation: </td>
        <td><input type="text" name="txtOccupation" value="" /></td>
    </tr>
    <tr>
        <td>Secret Question: </td>
        <td><input type="text" name="txtQuestion" value="" /></td>
    </tr>
    <tr>
        <td>Answer: </td>
        <td><input type="text" name="txtAnswer" value="" /></td>
    </tr>
</table>
</form>
<script>
//$("#focusForm input:first").focus();
//$("#focusForm :input").attr('disabled','disabled');
$("#focusForm :input").live("focus blur", function(e) {
    var el = $(this);
    el.toggleClass("focused", el.is(":focus"));
});
</script>

Cheers!