<?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/"
	>

<channel>
	<title>Public Mindmysql</title>
	<atom:link href="http://publicmind.in/blog/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://publicmind.in/blog</link>
	<description>Simple and Sophisticated</description>
	<lastBuildDate>Fri, 27 May 2011 08:28:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>&#8220;What is Drupal?&#8221;, for newbies</title>
		<link>http://publicmind.in/blog/what-is-drupal-for-newbies/</link>
		<comments>http://publicmind.in/blog/what-is-drupal-for-newbies/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 22:55:16 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=432</guid>
		<description><![CDATA[I often come across this question from my friends and peers and most of the time I deflect it by saying &#8220;it lets you create your website easily, why don&#8217;t you look up on Wikipedia?&#8221;. Few days ago, one of my friends pointed me that most of the articles start with &#8220;Drupal is a Content Management [...]]]></description>
			<content:encoded><![CDATA[<p>I often come across this question from my friends and peers and most of the time I deflect it by saying &#8220;it lets you create your website easily, why don&#8217;t you look up on Wikipedia?&#8221;. Few days ago, one of my friends pointed me that most of the articles start with &#8220;Drupal is a Content Management System(CMS) &#8230;&#8221; which becomes pretty much confusing when one has no idea about what a CMS is. In this post, I have tried to explain what a CMS is and why we need it and how Drupal stands out among various other available CMSs.</p>
<p>Let us say you need to create a webpage for your website. Ideally, it would mean you create HTML content that will be delivered to someone who requests it through their web browser. Eventually you grow big and decide to add 100 more pages to your website and therefore create 100 more HTML pages. But then you realize that there is a lot of duplicate content. The footer which contains the copyright information is essentially the same on all pages, therefore if you ever need to edit it then it would mean to edit these 101 pages. This will be a lot of redundant work.<br />
<span id="more-432"></span><br />
The main problem with the HTML pages is that they are static, they can not be changed based on what user requests. Thats why we need to have two different pages, even if they are almost similar and just differ by a single line. But then we also need to send the HTML content to the web browsers. That is where scripting languages such as PHP, ASP, JSP come as a savior. These languages are capable of creating dynamic content. The data is usually stored in the database and whenever a request comes for a page, HTML content will be created from this data on-the-fly and will be sent back to the requesting user. Now, you just need to store that copyright information just once, hence changing it becomes much easier.</p>
<p>Now, you also want to control which users have permission to access certain portion of the website and you create a login page for that part of the website, store cookies and write other code to maintain the session for the user. You might also want to publish a webpage on the fly, i.e.  save content to the database right from the user browser. You need some kind of access control mechanism and believe me it will be a hell lot of work to do.</p>
<p>That is where web-based Content Management System come into picture. They take out all the programming part from the publishing part of your website. You just need to write the content that has to be published on your website, make some settings on how it will be displayed, whether anyone or only authenticated users can see that content and you are done (of course, this is overly simplified but believe me once you know this everything will look so obvious to you).</p>
<p>With a CMS, one can easily create a website which :</p>
<ol>
<li>allows large number of people to contribute and share data.</li>
<li>easily manages user access control lists.</li>
<li>have reduced duplicate content.</li>
</ol>
<p>Drupal is one of the several available CMS is the market which is written in PHP and uses MySQL or PostgreSQL as database to store the website content. Drupal is released under GNU General Public License.</p>
<p><strong>What can you achieve with Drupal?</strong></p>
<p>You can easily create and manage,</p>
<ul>
<li>personal homepage</li>
<li>company website</li>
<li>blog</li>
<li>shopping websites (just like Ebay or Amazon)</li>
<li>Social networking sites like Twitter or Facebook</li>
</ul>
<p>With Drupal, you can create any kind of website, Imagination is the limit. Just FYI, White House uses Drupal to manage its official website: <a href="http://whitehouse.gov">whitehouse.gov</a></p>
<p>As with every other product, there are several other alternatives to Drupal such as Joomla, TYPO3, Nucleus, WordPress, etc. You can find the whole list of available CMS here: <a href="http://en.wikipedia.org/wiki/List_of_content_management_systems" target="_blank">List of Content Management Systems</a>. But what makes Drupal stand out is :</p>
<ol>
<li>its ease of use</li>
<li>a large community of developers which keeps everything secure and up to date.</li>
<li>a large pool of modules and themes. A module in Drupal lets you do things which aren&#8217;t supported by default in Drupal.</li>
</ol>
<p>Here is a small 1 minute video on &#8220;What is Drupal&#8221;, this video has already won six Telly awards:</p>
<p><object width="425" height="349"><param name="movie" value="http://www.youtube.com/v/rF1X12PE6PY&#038;rel=0&#038;border=1&#038;color1=0x3a3a3a&#038;color2=0x999999&#038;hl=en_US&#038;feature=player_embedded&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/rF1X12PE6PY&#038;rel=0&#038;border=1&#038;color1=0x3a3a3a&#038;color2=0x999999&#038;hl=en_US&#038;feature=player_embedded&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="349"></embed></object></p>
<p><strong>Drupal Website Hosting</strong></p>
<p><strong></strong>There are a lot of web hosting providers in the market and I know you will research well before buying anything. Most of them provide a one-click Drupal installation which saves you a lot of trouble while installing Drupal. I recommend you to look for such a web host, well all is up to you anyway.</p>
<p>You are now ready to eat up the Wikipedia article on Drupal. You can visit official Drupal website to look for great tutorials and downloads. Here are a few important links:</p>
<p>Official Drupal website: <a href="http://drupal.org">http://drupal.org</a><br />
Modules Resource: <a href="http://drupal.org/project/modules">http://drupal.org/project/modules</a><br />
Themes Resource: <a href="http://drupal.org/project/themes">http://drupal.org/project/themes</a><br />
Wikipedia article: <a href="http://en.wikipedia.org/wiki/Drupal">http://en.wikipedia.org/wiki/Drupal</a></p>
<p>Do not forget to vote for this post on DZone or Digg if you liked it, or you can leave a comment or two.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/what-is-drupal-for-newbies/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MYSQL: MINUS (Set Difference) Operator</title>
		<link>http://publicmind.in/blog/mysql-minus-set-difference-operator/</link>
		<comments>http://publicmind.in/blog/mysql-minus-set-difference-operator/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 22:26:02 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[Intern]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=192</guid>
		<description><![CDATA[Often we need MINUS operator as defined by the SQL definitions i.e you have two sets P and Q and you want P-Q which gives all the elements in P that are not in Q. But unfortunately, MYSQL does not have any operator for such an operation (yeah, I had the same reaction when I [...]]]></description>
			<content:encoded><![CDATA[<p>Often we need MINUS operator as defined by the SQL definitions i.e you have two sets P and Q and you want P-Q which gives all the elements in P that are not in Q. But unfortunately, MYSQL does not have any operator for such an operation (yeah, I had the same reaction when I heard this!!).</p>
<p>So here is a way how you can implement it in MYSQL. For simplicity let us consider we have two tables <strong>P and Q</strong> (we can also have views, joins, etc instead of the tables here) which have atleast one column in common (say <strong>id</strong>, which usually will be the primary key) and we want to evaluate <strong>P &#8211; Q</strong> which removes all those rows from P whose <strong>id</strong> is present in Q.</p>
<p>Here is the SQL statement for it. The statement is quite self explanatory, but if you still have doubt then leave a comment.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Select <span style="color: #339933;">*</span> from P left join Q on P.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> Q.<span style="color: #006633;">id</span> where Q.<span style="color: #006633;">id</span> is <span style="color: #000066; font-weight: bold;">NULL</span><span style="color: #339933;">;</span></div></div>
<p>Thats is what I could think of. If you are using some better and efficient method, then please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/mysql-minus-set-difference-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL: Get the Auto-Increment Values after Insert Statement</title>
		<link>http://publicmind.in/blog/mysql-auto-increment-values/</link>
		<comments>http://publicmind.in/blog/mysql-auto-increment-values/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 12:24:32 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[Intern]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=218</guid>
		<description><![CDATA[Until sometime back, I was unaware of how I could get the value of an auto-incremented field after an Insert Statement. But recently I needed it for two of my projects simultaneously, so I explored the possibilities. As one of my project is in Java and other is in PHP, we will go through both [...]]]></description>
			<content:encoded><![CDATA[<p>Until sometime back, I was unaware of how I could get the value of an auto-incremented field after an Insert Statement. But recently I needed it for two of my projects simultaneously, so I explored the possibilities. As one of my project is in Java and other is in PHP, we will go through both of them. </p>
<p>So, here is the problem. In general, the PRIMARY KEY field is the AUTO_INCREMENT field. Now wen you insert a row, a new key is generated and you can&#8217;t get it through usual way as this row can be accessed only using the primary key.</p>
<p>So here is how it can be done:<br />
<span id="more-218"></span><br />
<strong>In JAVA: </strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/*Insert a row into the desired table that generates <br />
an auto increment field*/</span><br />
<br />
stmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Insert into tableName (col1, col2) values (val1, val2)&quot;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astatement+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Statement</span></a>.<span style="color: #006633;">RETURN_GENERATED_KEYS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aresultset+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ResultSet</span></a> rs <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">getGeneratedKeys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">int</span> autoIncValue <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;autoIncValue <span style="color: #339933;">=</span> rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*You can get more generated keys if they are generated in your code*/</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><strong>In PHP</strong>:</p>
<p>The mysql_insert_id() function in PHP returns the AUTO_INCREMENT ID generated from the previous INSERT operation.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$con</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hostname&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error while connecting: '</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$db_selected</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span>database_name<span style="color: #339933;">,</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO tablename VALUES (val1,val2)&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;ID of last inserted record is: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_insert_id"><span style="color: #990000;">mysql_insert_id</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://www.php.net/mysql_close"><span style="color: #990000;">mysql_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Note: Be sure to call mysql_insert_id() immediately after a query to get the correct value. The function returns 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established. </p>
<p>Enjoy!!</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/mysql-auto-increment-values/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

