<!– something random just like junk – yard –>

PHP & MySQL quick search bookmarklets

Posted in LAMP, learning, opensource, tips by ganu on January 25, 2009

If you want to quick search to MySQL, here is the fast quick bookmarklet

javascript:q=document.getSelection();
if(!q)void(q=prompt('MySQL%20Keyword:',''));
if(q)location.href='http://search.mysql.com/search?q='+escape(q)

And the same goes for PHP too same like above…

javascript:term=document.getSelection();
if(!term)void(term=prompt('PHP%20Keyword:',''));
if(term)location.href='http://in2.php.net/'+escape(term)

Happy Programming. :D

quick symfony tips.

Posted in LAMP, learning by ganu on June 23, 2008

I am learning symfony. Just got some good tips to share with you.
Symfony rocks. :)

I will update this regularly.

1> How to write OR condition query in symfony.
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(TablePeer::TBL_ID);
$cton1 = $c->getNewCriterion(TABLEPEER::TBL_ID1, $some_condition , Criteria::EQUAL);
$cton2 = $c->getNewCriterion(TABLEPEER::TBL_ID1, $some_condition , Criteria::EQUAL);
$cton1->addOr($cton2);
$c->add($cton1);

2> How to get query where first date greater then and less then last date.
$date1 = date('Y-m-d 00:00:00');
$date2 = date('Y-m-d 23:59:59');
$cton1 = $gUser->getNewCriterion(TABLEPEER::TBLE_CREATEDAT, $date1, Criteria::GREATER_EQUAL);
$cton1->addAnd($gUser->getNewCriterion(TABLEPEER::TBLE_CREATEDAT, $date2, Criteria::LESS_EQUAL));
$gUser->add($cton1);

3> how to run the update query in symfony.

“update table TableName set TableField1=’1′ where TableField2=$some_value.”

$update = new TableName();
$update->setNew(false);
$update->setTableField1(1);
$update->setTableField2($imageId); // this is primary key of the table. include this line.
$update->save();
?>

technorati tags:
, , , , (more…)

Tagged with: , , , ,

Find last day of the month in PHP

Posted in LAMP, learning by ganu on February 28, 2007

Yday I was working with dates and got the situation to get the last day of the month so got this piece of code.

date(’Y-m-d’,strtotime(’-1 second’,strtotime(’+1 month’,strtotime(date(’m').’/01/’.date(’Y').’ 00:00:00′))));

And this piece of code will gv you the last day of the your corrent month. 

tags: , , ,