<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3678087349715948595</id><updated>2024-09-01T06:28:04.061-07:00</updated><category term="MYSQL"/><category term="PHP"/><title type='text'>Serve...  having the power of rebounding</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://serbv.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3678087349715948595/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://serbv.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Rohit Roy</name><uri>http://www.blogger.com/profile/03500554949331496614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4asnxp3WXezNm6Vi-wsGRzsaudHNXN6bxrTl8SWutIwWjuskYnYuCUnrCat77U_0nYXIoCSVRwKs3KwZ8adtitAMYVIPQeD79BxnCVwjE-niFkB7Rstz9p8N2tw4Tq9g/s220/rohit1.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3678087349715948595.post-5118112603035089463</id><published>2010-05-28T21:38:00.000-07:00</published><updated>2010-05-28T21:50:03.775-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>What is Singleton Class</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 13px;&quot;&gt;A singleton class allows&lt;/span&gt;&lt;/span&gt;&amp;nbsp;only  one instance of an object to be used across the web application.&lt;br /&gt;
&lt;b&gt;Where it can be used:&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&amp;nbsp;During Database Connection where we want to share only one database connection throughout the web&amp;nbsp;application. So in this case make your database related operation through Singleton Design Pattern.&lt;/li&gt;
&lt;li&gt;To &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; white-space: pre;&quot;&gt;avoid error like&lt;b&gt; too many connection open.&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span id=&quot;more-102&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;php&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #339933;&quot;&gt;&lt;pre class=&quot;php&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;YourSingleTonClass&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;
 &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;private&lt;/span&gt; static &lt;span style=&quot;color: #000088;&quot;&gt;$instance&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
 &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999;&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999;&quot;&gt;)&lt;/span&gt;
 &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;
 &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&amp;nbsp;
 &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;getInstance&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;$instance&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;$instance&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; YourSingleTonClass&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;$instance&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;php&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;/pre&gt;&lt;pre class=&quot;php&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;Description of Logic:&lt;/span&gt;&lt;/strong&gt;


&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;Declare the constructor &quot;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;private&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;&quot; so this can not be called outside of class.As constructor can not be called out side of class so this class cannot be instantiated.&lt;/span&gt;&lt;/li&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;Now declared an static variable &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;$instance&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; that will hold the object. With the static data type $instance will hold the object till  the class is alive.&lt;/span&gt;&lt;/li&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt; &lt;/span&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;Now i have made one method called getInstance(), it will check whether $instance already has some object, if it already has some object then it will  return that object instance otherwise will assign an new object to this variable.&lt;/span&gt;&lt;/li&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #674ea7;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;so only one instance at any time, now implement this class for database connection to avoid error&lt;/span&gt; like too many connection open.&lt;/span&gt;&lt;/b&gt;&lt;/ul&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://serbv.blogspot.com/feeds/5118112603035089463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://serbv.blogspot.com/2010/05/what-is-singleton-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3678087349715948595/posts/default/5118112603035089463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3678087349715948595/posts/default/5118112603035089463'/><link rel='alternate' type='text/html' href='http://serbv.blogspot.com/2010/05/what-is-singleton-class.html' title='What is Singleton Class'/><author><name>Rohit Roy</name><uri>http://www.blogger.com/profile/03500554949331496614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4asnxp3WXezNm6Vi-wsGRzsaudHNXN6bxrTl8SWutIwWjuskYnYuCUnrCat77U_0nYXIoCSVRwKs3KwZ8adtitAMYVIPQeD79BxnCVwjE-niFkB7Rstz9p8N2tw4Tq9g/s220/rohit1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3678087349715948595.post-2823387067547690311</id><published>2010-05-22T12:12:00.000-07:00</published><updated>2010-05-23T00:34:27.958-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MYSQL"/><title type='text'>Sort varchar numerically in Mysql</title><content type='html'>You may have faced this problem to sort data in ascending or descending order if datatype is varchar.&lt;br /&gt;
For example:&lt;br /&gt;
you have a table named  &lt;span style=&quot;font-weight: bold;&quot;&gt;&quot;tablename&quot;  &lt;/span&gt;and a field name is&lt;span style=&quot;font-weight: bold;&quot;&gt;  &quot;price&quot;&lt;/span&gt; with data type varchar&lt;br /&gt;
and the values are as follows&lt;br /&gt;
0&lt;br /&gt;
100&lt;br /&gt;
200&lt;br /&gt;
50.5&lt;br /&gt;
150.&lt;br /&gt;
when you write sql like &quot;SELECT * FROM tablename ORDER BY price ASC &quot;&lt;br /&gt;
you will not be getting your result as per your query, &lt;span style=&quot;color: #666666; font-style: italic; font-weight: bold;&quot;&gt;so how will you sort your data as numerically&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #666666;&quot;&gt;Here is the way to sort data as numerically when data type is varchar&lt;/div&gt;&lt;div style=&quot;color: #666666; font-weight: bold;&quot;&gt;select * from `tablename` order by `fieldname` + 0  ASC&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://serbv.blogspot.com/feeds/2823387067547690311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://serbv.blogspot.com/2010/05/varchar-sorting-in-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3678087349715948595/posts/default/2823387067547690311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3678087349715948595/posts/default/2823387067547690311'/><link rel='alternate' type='text/html' href='http://serbv.blogspot.com/2010/05/varchar-sorting-in-mysql.html' title='Sort varchar numerically in Mysql'/><author><name>Rohit Roy</name><uri>http://www.blogger.com/profile/03500554949331496614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4asnxp3WXezNm6Vi-wsGRzsaudHNXN6bxrTl8SWutIwWjuskYnYuCUnrCat77U_0nYXIoCSVRwKs3KwZ8adtitAMYVIPQeD79BxnCVwjE-niFkB7Rstz9p8N2tw4Tq9g/s220/rohit1.JPG'/></author><thr:total>0</thr:total></entry></feed>