<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tushar Mahajan</title>
	<atom:link href="http://tusharmahajan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tusharmahajan.wordpress.com</link>
	<description>I Use Linux</description>
	<lastBuildDate>Wed, 08 Sep 2010 13:11:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tusharmahajan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tushar Mahajan</title>
		<link>http://tusharmahajan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tusharmahajan.wordpress.com/osd.xml" title="Tushar Mahajan" />
	<atom:link rel='hub' href='http://tusharmahajan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>MySQL Stored Procedure</title>
		<link>http://tusharmahajan.wordpress.com/2010/09/08/mysql-stored-procedure/</link>
		<comments>http://tusharmahajan.wordpress.com/2010/09/08/mysql-stored-procedure/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 12:56:35 +0000</pubDate>
		<dc:creator>tusharmahajan</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://tusharmahajan.wordpress.com/?p=88</guid>
		<description><![CDATA[What is a Stored Procedure? A store procedure is a SQL block which performs one or more specific task. A procedure has a header and a body. The header consists of name of the procedure and the parameters passed to the procedure. The body consists of declaration section and execution section. The syntax for creating [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tusharmahajan.wordpress.com&amp;blog=5724095&amp;post=88&amp;subd=tusharmahajan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><b>What is a Stored Procedure?</b><br />
A store procedure is a SQL block which performs one or more specific task. A procedure has a header and a body. The header consists of name of the procedure and the parameters passed to the procedure. The body consists of declaration section and execution section.</p>
<p>The syntax for creating a Stored Procedure is:</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">CREATE<br />
[DEFINER = { user | CURRENT_USER }]<br />
PROCEDURE sp_name ([proc_parameter[,...]])<br />
[characteristic ...] routine_body</p>
<p>proc_parameter:<br />
[ IN | OUT | INOUT ] param_name type</p>
<p>type:<br />
Any valid MySQL data type</p>
<p>characteristic:<br />
COMMENT &#8216;string&#8217;<br />
| LANGUAGE SQL<br />
| [NOT] DETERMINISTIC<br />
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }<br />
| SQL SECURITY { DEFINER | INVOKER }</p>
<p>routine_body:<br />
Valid SQL routine statement</p>
</div>
<p>Note : The syntax within [] indicate they are optional.</p>
<p>Please refer following URL for the reference.</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">http://dev.mysql.com/doc/refman/5.6/en/create-procedure.html</div>
<p>Create the `employee` table in your database as follow.</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">CREATE TABLE IF NOT EXISTS `employee` (<br />
`employee_id` int(11) NOT NULL AUTO_INCREMENT,<br />
`first_name` varchar(55) NOT NULL,<br />
`last_name` varchar(55) NOT NULL,<br />
`email_address` varchar(100) NOT NULL,<br />
`location` varchar(55) NOT NULL,<br />
PRIMARY KEY (`employee_id`)<br />
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;</div>
<p>Now we will write the Stored Procedure `EmployeeActions` to insert and update the records from and to the database.</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">DELIMITER $$</p>
<p>CREATE PROCEDURE `EmployeeActions`(<br />
IN paramAction TEXT,<br />
IN paramEmployeeId INTEGER,<br />
IN paramFirstName TEXT,<br />
IN paramLastName TEXT,<br />
IN paramEmailAddress TEXT,<br />
IN paramLocation TEXT<br />
)<br />
BEGIN</p>
<p>DECLARE varAction TEXT ;</p>
<p>CASE paramAction<br />
WHEN &#8216;New&#8217; THEN<br />
INSERT INTO<br />
employee<br />
(<br />
`employee_id`,<br />
`first_name`,<br />
`last_name`,<br />
`email_address`,<br />
`location`<br />
)<br />
VALUES<br />
(<br />
NULL,<br />
paramFirstName,<br />
paramLastName,<br />
paramEmailAddress,<br />
paramLocation<br />
);</p>
<p>WHEN &#8216;Update&#8217; THEN<br />
UPDATE<br />
employee<br />
SET<br />
first_name = paramFirstName,<br />
last_name = paramLastName,<br />
email_address = paramEmailAddress,<br />
location = paramLocation<br />
WHERE<br />
employee_id = paramEmployeeId;<br />
END CASE;<br />
END;</p>
<p>DELIMITER ;</p>
</div>
<p>Note: If you are using phpMyAdmin then please change the delimiter to $$.</p>
<p><b>Why Stored Procedure?</b></p>
<p>Stored Procedure are resides in the database and precomplied so any block of code can acess the procedure to insert and update the records. Since it is precomplied it will execute faster than the SQL query.</p>
<p><b>How to execute a Stored Procedure?</b></p>
<p>Now we are ready to insert and update the record to and from the database.</p>
<p>Insert :</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">call EmployeeActions(&#8216;New&#8217;,&#8221;,&#8217;Tushar&#8217;,'Mahajan&#8217;,'tushar.iuselinux@gmail.com&#8217;,'Pune&#8217;);</div>
<p>Update :</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">call EmployeeActions(&#8216;Update&#8217;,&#8217;1&#8242;,&#8217;Tushar&#8217;,'Mahajan&#8217;,'spiderphp@gmail.com&#8217;,'Pune&#8217;);﻿</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tusharmahajan.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tusharmahajan.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tusharmahajan.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tusharmahajan.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tusharmahajan.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tusharmahajan.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tusharmahajan.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tusharmahajan.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tusharmahajan.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tusharmahajan.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tusharmahajan.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tusharmahajan.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tusharmahajan.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tusharmahajan.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tusharmahajan.wordpress.com&amp;blog=5724095&amp;post=88&amp;subd=tusharmahajan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tusharmahajan.wordpress.com/2010/09/08/mysql-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/75f23bfbeff2d9296b667ce2f01d245a?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">tusharmahajan</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP &#8211; JSON &#8211; JQuery (Sweet Combination)</title>
		<link>http://tusharmahajan.wordpress.com/2010/01/16/php-json-jquery-sweet-combination/</link>
		<comments>http://tusharmahajan.wordpress.com/2010/01/16/php-json-jquery-sweet-combination/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 18:04:52 +0000</pubDate>
		<dc:creator>tusharmahajan</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JQuery PHP JSON]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP JSON]]></category>

		<guid isPermaLink="false">http://tusharmahajan.wordpress.com/?p=67</guid>
		<description><![CDATA[This is an article to show you an example of the how the JQuery (AJAX) works with PHP using JSON. To work with this code you basically need a JQuery library which you will get from http://jquery.com/ First include the jquery.js file in your .htm file as follows &#60;script language=”javascript” type=”text/javascript” src=”jquery.js”&#62; We are using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tusharmahajan.wordpress.com&amp;blog=5724095&amp;post=67&amp;subd=tusharmahajan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is an article to show you an example of the how the JQuery (AJAX) works with PHP using JSON.</p>
<p>To work with this code you basically need a JQuery library which you will get from <a href="http://jquery.com/">http://jquery.com/</a></p>
<p>First include the jquery.js file in your .htm file as follows</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">&lt;script language=”javascript” type=”text/javascript” src=”jquery.js”&gt;</div>
<p>We are using the JQuery(AJAX)  to fetch the records from server side using PHP in the form of JSON.</p>
<p><strong>JSON</strong> stands for <strong>Javascript Object Notation</strong>. It is nothing but the way to write the data in some specific format so that you can access easily as follows.</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">var personObject = { &#8220;firstName&#8221; : &#8220;Tushar&#8221; , &#8220;lastName&#8221;  : &#8220;Mahajan&#8221; , &#8220;address&#8221; : { &#8220;city&#8221; : &#8220;Pune&#8221; , &#8220;country&#8221; : &#8220;India&#8221; }  } ;</div>
<p>Access firstName from personObject: personObject.firstName</p>
<p>Access city from personObject: personObject.address.city</p>
<p>Now Suppose you need to fetch the records from server side by using asynchronously (<strong>AJAX</strong>)  then it is necessary that they should come in some specific format like <strong>JSON</strong>.</p>
<p><strong>PHP</strong> Code (get_person_details.php)  to create <strong>JSON</strong> object</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">&lt;?php</p>
<p>$personId = $_POST['id'] ;</p>
<p>/* Here write the code for mysql to fetch the record form  database and create an array as follows */</p>
<p>$person = array( &#8220;firstName&#8221; =&gt; &#8220;Tushar&#8221; , &#8220;lastName&#8221; =&gt; &#8220;Mahajan&#8221; , &#8220;address&#8221; =&gt; array( &#8220;city&#8221; =&gt; &#8220;Pune&#8221; , &#8220;country&#8221; =&gt; &#8220;India&#8221;) );</p>
<p>echo json_encode($person);</p>
<p>?&gt;</p>
</div>
<p>Now the following <strong>JQuery</strong> Code create an <strong>AJAX</strong> request.</p>
<div style="border:1px dashed #777777;font-size:12px;padding:10px;">$(document).ready(function(){<br />
var url = &#8220;/person/get_person_details.php&#8221;;</p>
<p>$.post( url , { id : 12 } , function(data){</p>
<p>// the {data} is now a JSON object that is created by PHP Code.<br />
alert(data.firstName + &#8221; &#8221; + data.lastName);<br />
alert(data.address.city + &#8221; &#8221; + data.address.country );</p>
<p>}, JSON});<br />
});</p>
</div>
<p>So by this way you can eaisly acess the data comming from PHP using JSON.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tusharmahajan.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tusharmahajan.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tusharmahajan.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tusharmahajan.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tusharmahajan.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tusharmahajan.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tusharmahajan.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tusharmahajan.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tusharmahajan.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tusharmahajan.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tusharmahajan.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tusharmahajan.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tusharmahajan.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tusharmahajan.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tusharmahajan.wordpress.com&amp;blog=5724095&amp;post=67&amp;subd=tusharmahajan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tusharmahajan.wordpress.com/2010/01/16/php-json-jquery-sweet-combination/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/75f23bfbeff2d9296b667ce2f01d245a?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">tusharmahajan</media:title>
		</media:content>
	</item>
		<item>
		<title>JQuery Event</title>
		<link>http://tusharmahajan.wordpress.com/2009/11/02/jquery-event/</link>
		<comments>http://tusharmahajan.wordpress.com/2009/11/02/jquery-event/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 11:18:24 +0000</pubDate>
		<dc:creator>tusharmahajan</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Jquery Event]]></category>

		<guid isPermaLink="false">http://tusharmahajan.wordpress.com/?p=8</guid>
		<description><![CDATA[This is a basic article which will help you, how to attach an events to the elements at runtime so that you can make a clean html code. To work with this code you basically need a JQuery library which you will get from http://jquery.com/ First include the jquery.js file in your .htm file as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tusharmahajan.wordpress.com&amp;blog=5724095&amp;post=8&amp;subd=tusharmahajan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a basic article which will help you, how to attach an events to the elements at runtime so that you can make a clean html code.</p>
<p>To work with this code you basically need a JQuery library which you will get from <a href="http://jquery.com/">http://jquery.com/</a></p>
<p>First include the jquery.js file in your .htm file as follows</p>
<div style="border:solid 1px #777777;border-style:dashed;padding:10px;">&lt;script language=&#8221;javascript&#8221; type=&#8221;text/javascript&#8221; src=&#8221;jquery.js&#8221;&gt;&lt;/script&gt;</div>
<p>I am goining to use following HTML code to explain how can we attach an event to the element.</p>
<div style="border:solid 1px #777777;border-style:dashed;padding:10px;">&lt;div&gt;<br />
&lt;h2 class=&#8221;row&#8221;&gt;<br />
&lt;a href=&#8221;#&#8221;&gt;Tab 1&lt;/a&gt;<br />
&lt;/h2&gt;<br />
&lt;h2 class=&#8221;row&#8221;&gt;<br />
&lt;a href=&#8221;#&#8221;&gt;Tab 2&lt;/a&gt;<br />
&lt;/h2&gt;<br />
&lt;h2 class=&#8221;row&#8221;&gt;<br />
&lt;a href=&#8221;#&#8221;&gt;Tab 3&lt;/a&gt;<br />
&lt;/h2&gt;<br />
&lt;/div&gt;</div>
<p>Now following JQuery code will attach an events to &lt;a&gt; tag</p>
<div style="border:solid 1px #777777;border-style:dashed;padding:10px;">$(document).ready(function(){<br />
$(&#8220;h2.row &gt; a &#8220;).click(function () {<br />
var innerHTML = $(this).html();<br />
alert(innerHTML) ;<br />
// or write your own code<br />
});<br />
});</div>
<p>In the above code $(document).ready(function(){ }); is similar to window.onload = function ( ) { } with a small difference that the $(document).ready(function(){ }); waits for document to load.</p>
<p>Once it is loaded then it will find the all<br />
&lt;h2&gt;&lt;a href=&#8221;#&#8221;&gt;bla bla bla&lt;/a&gt;&lt;/h2&gt; combination using $(&#8220;h2.row &gt; a &#8220;); the meaning of this statement is find all &lt;a&gt; tag which are under &lt;h2&gt; tag having class &#8220;row&#8221;</p>
<p>After finding such a element it will attach click event to it using $(&#8220;h2.row &gt;  a &#8220;).click(function( ) { // place your code here });</p>
<p>So by this way you can attach events to the elements without writing<br />
&lt;a href=&#8221;#&#8221; onClick=&#8221;showText(this)&#8221;&gt;bla bla bla&lt;/a&gt;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tusharmahajan.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tusharmahajan.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tusharmahajan.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tusharmahajan.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tusharmahajan.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tusharmahajan.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tusharmahajan.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tusharmahajan.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tusharmahajan.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tusharmahajan.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tusharmahajan.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tusharmahajan.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tusharmahajan.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tusharmahajan.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tusharmahajan.wordpress.com&amp;blog=5724095&amp;post=8&amp;subd=tusharmahajan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tusharmahajan.wordpress.com/2009/11/02/jquery-event/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/75f23bfbeff2d9296b667ce2f01d245a?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">tusharmahajan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
