<?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>Mukesh Chapagain&#039;s Blog &#187; MySQL</title>
	<atom:link href="http://blog.chapagain.com.np/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chapagain.com.np</link>
	<description>PHP Magento jQuery SQL Wordpress Joomla Programming &#38; Tutorial</description>
	<lastBuildDate>Tue, 07 Feb 2012 00:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Alter MySQL table to add &amp; drop column &amp; add Foreign Key</title>
		<link>http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/</link>
		<comments>http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 00:54:41 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[alter table]]></category>
		<category><![CDATA[foreign key]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=1576</guid>
		<description><![CDATA[This article shows:- - How to add column to mysql database table after the table has already been created - How to delete column from mysql database table after the table has already been created - How to add foreign key to table column after the table has already been created Basically, all this can [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
<li><a href='http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/' rel='bookmark' title='Permanent Link: 10 Very Useful SQL Queries with JOINS'>10 Very Useful SQL Queries with JOINS</a></li>
<li><a href='http://blog.chapagain.com.np/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This article shows:-</p>
<blockquote><p>
- How to add column to mysql database table after the table has already been created</p>
<p>- How to delete column from mysql database table after the table has already been created</p>
<p><span id="more-1576"></span></p>
<p>- How to add foreign key to table column after the table has already been created
</p></blockquote>
<p>Basically, all this can be done by &#8216;<strong>ALTER TABLE</strong>&#8216; statement. Here is an step-by-step tutorial on how we do it.</p>
<p><strong>Create parent table</strong><br />
<code><br />
CREATE TABLE IF NOT EXISTS parent(<br />
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,<br />
name VARCHAR(255) NOT NULL,<br />
description TEXT DEFAULT NULL,<br />
status TINYINT(1) NOT NULL,<br />
PRIMARY KEY(id)<br />
);<br />
</code></p>
<p><strong>Create child table</strong><br />
<code><br />
CREATE TABLE IF NOT EXISTS child(<br />
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,<br />
name VARCHAR(255) NOT NULL,<br />
description TEXT DEFAULT NULL,<br />
PRIMARY KEY(id)<br />
);<br />
</code></p>
<p>After we create both parent and child table, we remember that:- </p>
<blockquote><p>
- We have added an extra unnecessary column in parent table.<br />
- We have missed adding a column to child table.<br />
- And this column in child table should be the foreign key for the parent table.
</p></blockquote>
<p>So, our step would be:-</p>
<p><strong>First of all, delete the unncessary column from parent table</strong></p>
<p><code>ALTER TABLE parent DROP status;</code></p>
<p><strong>Secondly, add a new column in child table</strong></p>
<p><code>ALTER TABLE child ADD parent_id int(11);</code></p>
<p><strong>Finally, add foreign key contraint to the child table which relates to the parent table&#8217;s column (primary key)</strong></p>
<p><code>ALTER TABLE child ADD CONSTRAINT child_FK_1<br />
	FOREIGN KEY (parent_id) REFERENCES parent (id)<br />
	ON DELETE CASCADE;</code></p>
<p>More detail on MySQL foreign key and its implementation can be found on: <a href="http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/" target="_blank">MySQL Database: Foreign Key Understanding and Implementation</a></p>
<p>Thanks.</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=1576&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
<li><a href='http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/' rel='bookmark' title='Permanent Link: 10 Very Useful SQL Queries with JOINS'>10 Very Useful SQL Queries with JOINS</a></li>
<li><a href='http://blog.chapagain.com.np/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Database: Foreign Key Understanding and Implementation</title>
		<link>http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/</link>
		<comments>http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 02:22:52 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[cascade]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=1262</guid>
		<description><![CDATA[Some definitions of foreign key:- A FOREIGN KEY in one table points to a PRIMARY KEY in another table. A foreign key is a field in a relational table that matches the primary key of another table. The foreign key can be used to cross-reference tables. A table may have multiple foreign keys, and each [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/' rel='bookmark' title='Permanent Link: 10 Very Useful SQL Queries with JOINS'>10 Very Useful SQL Queries with JOINS</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Some definitions of foreign key:-</p>
<blockquote><p>A FOREIGN KEY in one table points to a PRIMARY KEY in another table.</p>
<p>A foreign key is a field in a relational table that matches the primary key of another table. The foreign key can be used to cross-reference tables. A table may have multiple foreign keys, and each foreign key can have a different referenced table.</p>
<p><span id="more-1262"></span></p>
<p>A Foreign Key is a Referential Constraint between two tables. A Referential Constraint or Referential Integrity is a property of data which, when satisfied, requires every value of one attribute (column) of a relation (table) to exist as a value of another attribute in a different (or the same) relation (table).
</p></blockquote>
<p>For MySQL, to support foreign key, the table type should be &#8216;<strong>InnoDB</strong>&#8216;. Therefore, when we are cross-referencing two tables through foreign key, both the tables must be InnoDB tables and they must not be Temporary tables.</p>
<p><strong>InnoDB </strong> also supports foreign key references within a table. The referencing and referenced table may be the same table, i.e. the foreign key refers back to the same table. Such a foreign key is known as a self-referencing or recursive foreign key.</p>
<p>When the user attempts to delete or update a row from a parent table, and there are one or more matching rows in the child table, InnoDB handles this through &#8220;<strong>Referential Action</strong>&#8220;. There are five options regarding the action to be taken. If <strong>ON DELETE</strong> or <strong>ON UPDATE</strong> are not specified, the default action is <strong>RESTRICT</strong>.</p>
<blockquote><p>
<strong>CASCADE</strong>: Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported. </p>
<p><strong>SET NULL</strong>: Delete or update the row from the parent table and set the foreign key column or columns in the child table to NULL. This is valid only if the foreign key columns do not have the NOT NULL qualifier specified. Both ON DELETE SET NULL and ON UPDATE SET NULL clauses are supported.</p>
<p><strong>NO ACTION</strong>: In standard SQL, NO ACTION means no action in the sense that an attempt to delete or update a primary key value is not permitted to proceed if there is a related foreign key value in the referenced table. InnoDB rejects the delete or update operation for the parent table.</p>
<p><strong>RESTRICT</strong>: Rejects the delete or update operation for the parent table. Specifying RESTRICT (or NO ACTION) is the same as omitting the ON DELETE or ON UPDATE clause. The main difference between NO ACTION and RESTRICT is that with NO ACTION the referential integrity check is done after trying to alter the table. RESTRICT does the check before trying to execute the UPDATE or DELETE statement. However, in MySQL, foreign key constraints are checked immediately, so NO ACTION is the same as RESTRICT.</p>
<p><strong>SET DEFAULT</strong>: Similar to SET NULL, the foreign key values in the referencing row are set to the column default when the referenced row is updated or deleted. This action is recognized by the parser, but InnoDB rejects table definitions containing ON DELETE SET DEFAULT or ON UPDATE SET DEFAULT clauses.
</p></blockquote>
<p>Here, I will be implementing the foreign key <strong>CASCADE </strong>update and delete.</p>
<p><strong>CASCADE</strong>:-</p>
<p>Whenever rows in the master (referenced) table are deleted, the respective rows of the child (referencing) table with a matching foreign key column will get deleted as well. This is called a cascade delete.</p>
<p>Example Tables: test_customer(customer_id, name, address) and test_order(order_id, customer_id, status)</p>
<p>test_customer is the master table and test_order is the child table, where &#8216;customer_id&#8217; is the foreign key in test_order and represents the customer who placed the order. When a row of test_customer is deleted, any test_order row matching the deleted test_customer&#8217;s customer_id will also be deleted.</p>
<p><strong>Create Tables</strong></p>
<p><code>CREATE TABLE test_customer (<br />
    customer_id int(10) unsigned NOT NULL auto_increment,<br />
    name varchar(100),<br />
    address varchar(100),<br />
    PRIMARY KEY (customer_id)<br />
) ENGINE=InnoDB;</p>
<p>CREATE TABLE test_order (<br />
    order_id int(10) unsigned NOT NULL auto_increment,<br />
    customer_id int(10) unsigned NOT NULL,<br />
    status varchar(30),<br />
    PRIMARY KEY (order_id)<br />
) ENGINE=InnoDB; </code></p>
<p><strong>Add Foreign Key</strong></p>
<p><code>ALTER TABLE test_order<br />
ADD CONSTRAINT FK_test_order<br />
FOREIGN KEY (customer_id) REFERENCES test_customer(customer_id)<br />
ON UPDATE CASCADE<br />
ON DELETE CASCADE; </code></p>
<p><strong>Alternative way</strong></p>
<p>Alternatively we can directly add Foreign Key at the time of table creation. You may choose any one way (the following way or the way above) for creating tables and assigning foreign key.</p>
<p><code>SET foreign_key_checks = 0;</p>
<p>CREATE TABLE test_customer (<br />
    customer_id int(10) unsigned NOT NULL auto_increment,<br />
    name varchar(100),<br />
    address varchar(100),<br />
    PRIMARY KEY (customer_id)<br />
) ENGINE=InnoDB;</p>
<p>CREATE TABLE test_order (<br />
    order_id int(10) unsigned NOT NULL auto_increment,<br />
    customer_id int(10) unsigned NOT NULL,<br />
    status varchar(30),<br />
    PRIMARY KEY (order_id),<br />
	CONSTRAINT FK_test_order<br />
	FOREIGN KEY (customer_id) REFERENCES test_customer(customer_id)<br />
	ON UPDATE CASCADE ON DELETE CASCADE<br />
) ENGINE=InnoDB; </p>
<p>SET foreign_key_checks = 1;</code></p>
<p><strong>Insert sample data to test_customer and test_order tables</strong></p>
<p><code>INSERT INTO  test_customer<br />
(  customer_id ,  name ,  address )<br />
VALUES<br />
( '1',  'John',  'New York' ),<br />
( '2',  'Tom',  'London' );</p>
<p>INSERT INTO  test_order<br />
(  order_id ,  customer_id ,  status )<br />
VALUES<br />
( '1',  '1',  'pending' ),<br />
( '2',  '1',  'processing' ),<br />
( '3',  '2',  'complete' ),<br />
( '4',  '2',  'pending' );</code></p>
<p><strong>Doing UPDATE CASCADE</strong></p>
<p>When we update customer_id in test_customer (parent table), the customer_id field in test_order (child table) will also get updated.</p>
<p><code>UPDATE test_customer SET customer_id = 3 WHERE customer_id = 1;</code></p>
<p><strong>Note</strong>:- </p>
<p>We <strong>CANNOT </strong>directly update the foreign key in child table. </p>
<p>Doing this will result in error saying &#8220;<em>Cannot add or update a child row: a foreign key constraint fails</em>&#8220;.</p>
<p><code>UPDATE test_order SET customer_id = 4 WHERE customer_id = 3;</code></p>
<p><strong>Doing DELETE CASCADE</strong></p>
<p>When we delete customer_id in test_customer (parent table), the customer_id field in test_order (child table) will also get deleted.</p>
<p><code>DELETE FROM test_customer WHERE customer_id = 2;</code></p>
<p><strong>Note</strong>:-</p>
<p>We <strong>CAN </strong>directly delete rows from test_order (child table) like below:-</p>
<p><code>DELETE FROM test_order WHERE customer_id = 3;</code></p>
<p>Hope this helps. Thanks</p>
<p><strong>References</strong>:-<br />
1. <a target="_blank" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html">http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html</a><br />
2. <a target="_blank" rel="nofollow" href="http://en.wikipedia.org/wiki/Foreign_key">http://en.wikipedia.org/wiki/Foreign_key</a></p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=1262&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/' rel='bookmark' title='Permanent Link: 10 Very Useful SQL Queries with JOINS'>10 Very Useful SQL Queries with JOINS</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Magento: Join, filter, select and sort attributes, fields and tables</title>
		<link>http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/</link>
		<comments>http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 14:34:06 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=981</guid>
		<description><![CDATA[In my previous article (Magento: Very Useful Collection Functions), I had written about database interaction functions present in class Varien_Data_Collection_Db. Here, I am going to explain some database interaction functions present in the class Mage_Eav_Model_Entity_Collection_Abstract. These collection functions are very useful to select data from Magento database. We need them almost all the time for [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/' rel='bookmark' title='Permanent Link: Magento: How to filter product collection using 2 or more category filters?'>Magento: How to filter product collection using 2 or more category filters?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-collection-functions/' rel='bookmark' title='Permanent Link: Magento: Very Useful Collection Functions'>Magento: Very Useful Collection Functions</a></li>
<li><a href='http://blog.chapagain.com.np/magento-adding-category-attributes/' rel='bookmark' title='Permanent Link: Magento: Adding category attributes'>Magento: Adding category attributes</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-search-or-filter-by-multiselect-attribute-in-admin-grid/' rel='bookmark' title='Permanent Link: Magento: How to search or filter by multiselect attribute in admin grid?'>Magento: How to search or filter by multiselect attribute in admin grid?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-sort-latest-product-by-created-date-and-new-from-date/' rel='bookmark' title='Permanent Link: Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;'>Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In my previous article (<strong><a href="http://blog.chapagain.com.np/magento-collection-functions/">Magento: Very Useful Collection Functions</a></strong>), I had written about database interaction functions present in class <strong>Varien_Data_Collection_Db</strong>.</p>
<p>Here, I am going to explain some database interaction functions present in the class <strong>Mage_Eav_Model_Entity_Collection_Abstract</strong>. These collection functions are very useful to select data from Magento database. We need them almost all the time for filtering collection object.</p>
<p><span id="more-981"></span></p>
<p>Below are some of the useful functions that we use most often.</p>
<p><strong>Class: Mage_Eav_Model_Entity_Collection_Abstract</strong></p>
<p><strong>addAttributeToFilter</strong>: adds WHERE clause on $attribute specified by $condition</p>
<blockquote><p>
/**<br />
* Add attribute filter to collection<br />
*<br />
* If $attribute is an array will add OR condition with following format:<br />
* array(<br />
*     array(&#8216;attribute&#8217;=&gt;&#8217;firstname&#8217;, &#8216;like&#8217;=&gt;&#8217;test%&#8217;),<br />
*     array(&#8216;attribute&#8217;=&gt;&#8217;lastname&#8217;, &#8216;like&#8217;=&gt;&#8217;test%&#8217;),<br />
* )<br />
*<br />
* @see self::_getConditionSql for $condition<br />
* @param Mage_Eav_Model_Entity_Attribute_Interface|integer|string|array $attribute<br />
* @param null|string|array $condition<br />
* @param string $operator<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addAttributeToFilter($attribute, $condition=null, $joinType=&#8217;inner&#8217;)
</p></blockquote>
<p><strong>addAttributeToSelect</strong>: gets the value for $attribute in the SELECT clause; specify * to get all attributes (i.e. to execute SELECT *)</p>
<blockquote><p>
/**<br />
* Add attribute to entities in collection<br />
*<br />
* If $attribute==&#8217;*&#8217; select all attributes<br />
*<br />
* @param   array|string|integer|Mage_Core_Model_Config_Element $attribute<br />
* @param   false|string $joinType flag for joining attribute<br />
* @return  Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addAttributeToSelect($attribute, $joinType=false)
</p></blockquote>
<p>If an array is passed but no attribute code specified, it will be interpreted as a group of OR conditions that will be processed in the same way.<br />
If no attribute code is specified, it defaults to eq.</p>
<pre class="brush: php; title: ; notranslate">
$collection = Mage::getModel('catalog/product')-&gt;getCollection();

// select all attributes
$collection-&gt;addAttributeToSelect('*');

// select specific attributes
$collection-&gt;addAttributeToSelect(array('name', 'url_key', 'type_id'));

// select only those items whose status = 1
$collection-&gt;addAttributeToFilter('status', 1);

// alternative to select only those items whose status = 1
$collection-&gt;addAttributeToFilter('status', array('eq' =&gt; 1));

// using LIKE statement
$collection-&gt;addAttributeToFilter('sku', array('like' =&gt; '%CH%'));

// using IN statement,
// i.e. selecting only those items whose ID fall in the given array
$collection-&gt;addAttributeToFilter('id', array('in' =&gt; array(1, 14, 51, 52)));

// selecting only those items whose ID is greater than the given value
$collection-&gt;addAttributeToFilter('id', array('gt' =&gt; 5));

// select by date range
$collection-&gt;addAttributeToFilter('date_field', array(
    'from' =&gt; '10 September 2010',
    'from' =&gt; '21 September 2010',
    'date' =&gt; true, // specifies conversion of comparison values
    ));

// Add OR condition:
$collection-&gt;addAttributeToFilter(array(
    array(
        'attribute' =&gt; 'field_name',
        'in'        =&gt; array(1, 2, 3),
        ),
    array(
        'attribute' =&gt; 'date_field',
        'from'      =&gt; '2010-09-10',
        ),
    ));
</pre>
<p><strong>Below is the full filter condition codes with attribute code and its sql equivalent</strong></p>
<blockquote><p>
eq	:	=<br />
neq	:	!=<br />
like :	LIKE<br />
nlike :	NOT LIKE<br />
in	:	IN ()<br />
nin	:	NOT IN ()<br />
is	:	IS<br />
notnull :	IS NOT NULL<br />
null :	IS NULL<br />
moreq :	>=<br />
gt	:	><br />
lt	:	<<br />
gteq :	>=<br />
lteq :	<=<br />
finset :	FIND_IN_SET()<br />
from :	>=	 (for use with dates)<br />
to	:	<=	 (for use with dates)<br />
date :	optional flag for use with from/to to specify that comparison value should first be converted to a date<br />
datetime :	optional flag for use with from/to to specify that comparison value should first be converted to a datetime
</p></blockquote>
<p><strong>addFieldToFilter</strong>: alias for addAttributeToFilter(). This filters the database table fields.</p>
<blockquote><p>
/**<br />
* Wrapper for compatibility with Varien_Data_Collection_Db<br />
*<br />
* @param mixed $attribute<br />
* @param mixed $condition<br />
*/<br />
addFieldToFilter($attribute, $condition=null)
</p></blockquote>
<p><strong>addAttributeToSort</strong>: adds ORDER BY clause on $attribute</p>
<blockquote><p>
/**<br />
* Add attribute to sort order<br />
*<br />
* @param string $attribute<br />
* @param string $dir<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addAttributeToSort($attribute, $dir=&#8217;asc&#8217;)
</p></blockquote>
<p><strong>addExpressionAttributeToSelect</strong>: adds SQL expression $expression, using $alias, to SELECT clause (typically containing aggregate functions such as SUM(), COUNT()); when $attribute specifies a single attribute as a string, $expression can reference the attribute as simply {{attribute}}, but when passing an array of attributes, each attribute must be referenced in $expression by the name of the specific attribute;</p>
<blockquote><p>
/**<br />
* Add attribute expression (SUM, COUNT, etc)<br />
*<br />
* Example: (&#8216;sub_total&#8217;, &#8216;SUM({{attribute}})&#8217;, &#8216;revenue&#8217;)<br />
* Example: (&#8216;sub_total&#8217;, &#8216;SUM({{revenue}})&#8217;, &#8216;revenue&#8217;)<br />
*<br />
* For some functions like SUM use groupByAttribute.<br />
*<br />
* @param string $alias<br />
* @param string $expression<br />
* @param string $attribute<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addExpressionAttributeToSelect($alias, $expression, $attribute)
</p></blockquote>
<p><strong>groupByAttribute</strong>: adds $attribute to GROUP BY clause</p>
<blockquote><p>
/**<br />
* Groups results by specified attribute<br />
*<br />
* @param string|array $attribute<br />
*/<br />
groupByAttribute($attribute)
</p></blockquote>
<p><strong>joinAttribute</strong>: joins another entity and adds attribute from joined entity, using $alias, to SELECT clause.</p>
<p>Here are the parameters for joinAttribute function:-</p>
<p><strong>$alias</strong> = selected field name. You can keep it&#8217;s name whatever you want.</p>
<p><strong>$attribute</strong> = joined entity type code and attribute code = <strong>entity_type_code/attribute_code</strong><br />
<strong>entity_type_code</strong> is present in <strong>eav_entity_type table</strong><br />
<strong>attribute_code</strong> is present in <strong>eav_attribute table</strong><br />
attribute_code is attribute of the corresponding entity you want to select out.</p>
<p><strong>$bind</strong> = attribute code of the main entity to link to the joined entity.</p>
<p><strong>$filter</strong> = primary key for the joined entity (entity_id default)</p>
<blockquote><p>
/**<br />
* Add attribute from joined entity to select<br />
*<br />
* Examples:<br />
* (&#8216;billing_firstname&#8217;, &#8216;customer_address/firstname&#8217;, &#8216;default_billing&#8217;)<br />
* (&#8216;billing_lastname&#8217;, &#8216;customer_address/lastname&#8217;, &#8216;default_billing&#8217;)<br />
* (&#8216;shipping_lastname&#8217;, &#8216;customer_address/lastname&#8217;, &#8216;default_billing&#8217;)<br />
* (&#8216;shipping_postalcode&#8217;, &#8216;customer_address/postalcode&#8217;, &#8216;default_shipping&#8217;)<br />
* (&#8216;shipping_city&#8217;, $cityAttribute, &#8216;default_shipping&#8217;)<br />
*<br />
* Developer is encouraged to use existing instances of attributes and entities<br />
* After first use of string entity name it will be cached in the collection<br />
*<br />
* @todo connect between joined attributes of same entity<br />
* @param string $alias alias for the joined attribute<br />
* @param string|Mage_Eav_Model_Entity_Attribute_Abstract $attribute<br />
* @param string $bind attribute of the main entity to link with joined $filter<br />
* @param string $filter primary key for the joined entity (entity_id default)<br />
* @param string $joinType inner|left<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
joinAttribute($alias, $attribute, $bind, $filter=null, $joinType=&#8217;inner&#8217;, $storeId=null)
</p></blockquote>
<p><strong>joinTable</strong>: joins table $table</p>
<p>Here are the parameters of the function joinTable:-</p>
<p>$table = table name to join<br />
$bind = ( parent_key = foreign_key )<br />
$fields = array of fields to select<br />
$cond = where condition<br />
$joinType = join type</p>
<blockquote><p>
/**<br />
* Join a table<br />
*<br />
* @param string|array $table<br />
* @param string $bind<br />
* @param string|array $fields<br />
* @param null|array $cond<br />
* @param string $joinType<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
joinTable($table, $bind, $fields=null, $cond=null, $joinType=&#8217;inner&#8217;)
</p></blockquote>
<p><strong>Using joinAttribute and joinTable</strong></p>
<p>In the code below, all order invoice items are selected, i.e. all products that have been invoiced.<br />
joinTable is used to join sales_order_entity table to fetch increment_id and store_id of the invoice for each product.<br />
joinAttribute is used to fetch order_id, product_name, and store_id.<br />
joinTable is used again to fetch the order status of each invoice item.</p>
<pre class="brush: php; title: ; notranslate">
$collection = Mage::getModel('sales/order_invoice_item')
					-&gt;getCollection()
					-&gt;joinTable('sales_order_entity', 'entity_id=parent_id', array('invoice_id'=&gt;'increment_id', 'store_id' =&gt; 'store_id'), null , 'left')
					-&gt;joinAttribute('order_id', 'invoice/order_id', 'parent_id', null, 'left')
					-&gt;joinAttribute('product_name', 'invoice_item/name', 'entity_id', null, 'left')
					-&gt;joinAttribute('store_id', 'invoice/store_id', 'parent_id', null, 'left')

					-&gt;joinTable('sales_order', 'entity_id=order_id', array('order_status'=&gt;'status'), null , 'left')
					;
</pre>
<p><strong>joinField</strong>: joins regular table field using an attribute as foreign key</p>
<blockquote><p>
/**<br />
* Join regular table field and use an attribute as fk<br />
*<br />
* Examples:<br />
* (&#8216;country_name&#8217;, &#8216;directory/country_name&#8217;, &#8216;name&#8217;, &#8216;country_id=shipping_country&#8217;, &#8220;{{table}}.language_code=&#8217;en&#8217;&#8221;, &#8216;left&#8217;)<br />
*<br />
* @param string $alias &#8216;country_name&#8217;<br />
* @param string $table &#8216;directory/country_name&#8217;<br />
* @param string $field &#8216;name&#8217;<br />
* @param string $bind &#8216;PK(country_id)=FK(shipping_country_id)&#8217;<br />
* @param string|array $cond &#8220;{{table}}.language_code=&#8217;en&#8217;&#8221; OR array(&#8216;language_code&#8217;=&gt;&#8217;en&#8217;)<br />
* @param string $joinType &#8216;left&#8217;<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
joinField($alias, $table, $field, $bind, $cond=null, $joinType=&#8217;inner&#8217;)
</p></blockquote>
<p><strong>removeAttributeToSelect</strong>: removes $attribute from SELECT clause; specify null to remove all attributes</p>
<blockquote><p>
/**<br />
* Remove an attribute from selection list<br />
*<br />
* @param string $attribute<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
removeAttributeToSelect($attribute=null)
</p></blockquote>
<p><strong>setPage</strong>: sets LIMIT clause by specifying page number (one-indexed) and number of records per page; equivalent to calling setCurPage($pageNum) and setPageSize($pageSize)</p>
<blockquote><p>
/**<br />
* Set collection page start and records to show<br />
*<br />
* @param integer $pageNum<br />
* @param integer $pageSize<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
setPage($pageNum, $pageSize)
</p></blockquote>
<p><strong>importFromArray</strong>: imports 2D array into collection as objects</p>
<blockquote><p>
/**<br />
* Import 2D array into collection as objects<br />
*<br />
* If the imported items already exist, update the data for existing objects<br />
*<br />
* @param array $arr<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
importFromArray($arr)
</p></blockquote>
<p><strong>exportToArray</strong>: returns collection data as a 2D array</p>
<blockquote><p>
/**<br />
* Get collection data as a 2D array<br />
*<br />
* @return array<br />
*/<br />
exportToArray()
</p></blockquote>
<p><strong>setOrder</strong>: alias for addAttributeToSort() q.v., identical except that it can accept array of attributes, and default $dir is desc</p>
<blockquote><p>
/**<br />
* Set sorting order<br />
*<br />
* $attribute can also be an array of attributes<br />
*<br />
* @param string|array $attribute<br />
* @param string $dir<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
setOrder($attribute, $dir=&#8217;desc&#8217;)
</p></blockquote>
<blockquote><p>Inspired by Magento Wiki:<br />
<a href="http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/using_collections_in_magento" rel="nofollow" target="_blank">http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/using_collections_in_magento</a>.<br />
However, more of my code, text &#038; understanding are added in this article.
</p></blockquote>
<p>Hope this helps. Thanks.</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=981&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/' rel='bookmark' title='Permanent Link: Magento: How to filter product collection using 2 or more category filters?'>Magento: How to filter product collection using 2 or more category filters?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-collection-functions/' rel='bookmark' title='Permanent Link: Magento: Very Useful Collection Functions'>Magento: Very Useful Collection Functions</a></li>
<li><a href='http://blog.chapagain.com.np/magento-adding-category-attributes/' rel='bookmark' title='Permanent Link: Magento: Adding category attributes'>Magento: Adding category attributes</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-search-or-filter-by-multiselect-attribute-in-admin-grid/' rel='bookmark' title='Permanent Link: Magento: How to search or filter by multiselect attribute in admin grid?'>Magento: How to search or filter by multiselect attribute in admin grid?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-sort-latest-product-by-created-date-and-new-from-date/' rel='bookmark' title='Permanent Link: Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;'>Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>10 Very Useful SQL Queries with JOINS</title>
		<link>http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/</link>
		<comments>http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/#comments</comments>
		<pubDate>Fri, 14 May 2010 19:30:10 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=779</guid>
		<description><![CDATA[The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. [@via w3schools] A SQL JOIN clause combines records from two or more tables in a database. It creates a set that can be saved as a table or [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/' rel='bookmark' title='Permanent Link: Magento: Join, filter, select and sort attributes, fields and tables'>Magento: Join, filter, select and sort attributes, fields and tables</a></li>
<li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<blockquote><p>The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. [@via w3schools]</p></blockquote>
<blockquote><p>A SQL JOIN clause combines records from two or more tables in a database. It creates a set that can be saved as a table or used as is. A JOIN is a means for combining fields from two tables by using values common to each. ANSI standard SQL specifies four types of JOINs: INNER, OUTER, LEFT, and RIGHT. In special cases, a table (base table, view, or joined table) can JOIN to itself in a self-join. [@via wikipedia]</p></blockquote>
<p><span id="more-779"></span></p>
<p>SQL Joins are helpful when we have to fetch data with a single query from two or more database tables.</p>
<p><strong>Case:</strong></p>
<p>I need to store news/article information. The news can also have comments and tags. News can be submitted/posted by multiple users.</p>
<p>According to the above scenario, I have created 5 tables and inserted some data into them :-</p>
<p><strong>news </strong>- to store news<br />
<strong>comments </strong>- to store comments for any particular news<br />
<strong>tags </strong>- to store tags associated with any particular news<br />
<strong>users </strong>- to store user information<br />
<strong>tags_news</strong> &#8211; to store relationship between news and tags</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `comments`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `comments` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `news_id` bigint(20) NOT NULL,<br />
  `user_id` bigint(20) NOT NULL,<br />
  `detail` text NOT NULL,<br />
  `status` tinyint(1) NOT NULL default '1',<br />
  `comment_date` int(11) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `user_id` (`user_id`),<br />
  KEY `news_id` (`news_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code></p>
<p>&#8211;<br />
&#8211; <strong>Dumping data for table `comments`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `comments` (`id`, `news_id`, `user_id`, `detail`, `status`, `comment_date`) VALUES<br />
(1, 1, 2, 'nice post :)', 1, 1273431296),<br />
(2, 2, 2, 'hahaha', 1, 1273431420),<br />
(3, 3, 2, '3123123', 1, 1273431452),<br />
(4, 1, 2, 'thank You', 1, 1273431475),<br />
(5, 2, 1, 'congratulations!', 1, 1273431500);<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `news`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `news` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `user_id` bigint(20) NOT NULL,<br />
  `title` text NOT NULL,<br />
  `detail` text NOT NULL,<br />
  `visit` int(11) NOT NULL default '0',<br />
  `status` tinyint(1) NOT NULL default '1',<br />
  `created_date` int(11) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `user_id` (`user_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `news`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `news` (`id`, `user_id`, `title`, `detail`, `visit`, `status`, `created_date`) VALUES<br />
(1, 1, 'Extra Content', 'fasdfasdf', 2, 1, 1273431296),<br />
(2, 1, 'My My Question', 'this is jpt question.. :D', 16, 1, 1273431389),<br />
(3, 2, 'Am I ram?', 'I am ram..yahoo !!', 3, 1, 1273431420);<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `tags`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `tags` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `name` varchar(255) NOT NULL,<br />
  `slug` varchar(255) NOT NULL,<br />
  PRIMARY KEY  (`id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `tags`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `tags` (`id`, `name`, `slug`) VALUES<br />
(1, 'sagarmatha', 'sagarmatha'),<br />
(2, 'nepal', 'nepal'),<br />
(3, 'gautam buddha', 'gautam-buddha'),<br />
(4, 'testing', 'testing'),<br />
(5, 'tags', 'tags'),<br />
(6, 'tasty apple', 'tasty-apple'),<br />
(7, 'banana', 'banana');<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `tags_news`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `tags_news` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `news_id` bigint(20) NOT NULL,<br />
  `tags_id` bigint(20) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `news_id` (`news_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `tags_news`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `tags_news` (`id`, `news_id`, `tags_id`) VALUES<br />
(1, 1, 1),<br />
(2, 1, 2),<br />
(3, 1, 3),<br />
(4, 2, 4),<br />
(5, 2, 5),<br />
(6, 2, 6),<br />
(7, 3, 6),<br />
(8, 3, 7);<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `users`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `users` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `user_id` bigint(20) NOT NULL,<br />
  `firstname` varchar(100) NOT NULL,<br />
  `lastname` varchar(100) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `user_id` (`user_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `users`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `users` (`id`, `user_id`, `firstname`, `lastname`) VALUES<br />
(1, 1, 'Mukesh', 'Chapagain'),<br />
(2, 2, 'Christopher', 'Gayle'),<br />
(3, 3, 'Brian', 'Lara');<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Now, by using SQL JOINS, I can fetch data from these tables for different conditions and in different ways. Here follows the different SQL Queries with the magical JOIN statements:-</p>
<p><strong>1) SELECT NEWS WITH COMMENTS COUNT FOR EACH NEWS</strong></p>
<p><code><br />
SELECT n.*, ifnull(c.count,0) AS comment FROM news AS n<br />
	LEFT JOIN<br />
		(SELECT COUNT(comments.id) AS count, comments.news_id FROM comments GROUP BY comments.news_id) AS c<br />
			ON n.id = c.news_id<br />
				ORDER BY n.created_date DESC;<br />
</code>		</p>
<p><strong>2) SELECT NEWS POSTED BY ANY PARTICULAR USER (HERE, user_id = 1)</strong></p>
<p><code><br />
SELECT n.* FROM news AS n<br />
	INNER JOIN<br />
		users AS u<br />
			ON n.user_id = u.id<br />
				WHERE u.id = 1;<br />
</code></p>
<p><strong>3) SELECT NEWS POSTED BY ANY PARTICULAR USER (WITH USER&#8217;S FIRSTNAME AND LASTNAME) (HERE, user_id = 1)</strong></p>
<p><code><br />
SELECT n.*, u.firstname AS firstname, u.lastname AS lastname FROM news AS n<br />
	INNER JOIN<br />
		users AS u<br />
			ON n.user_id = u.id<br />
				WHERE u.id = 1;<br />
</code>			</p>
<p><strong>4) SELECT NEWS POSTED BY ANY PARTICULAR USER (WITH COMMENTS COUNT FOR EACH NEWS) (HERE, user_id = 1)</strong></p>
<p><code><br />
SELECT n.*, ifnull(c.count,0) AS comment, u.firstname AS firstname, u.lastname AS lastname FROM news AS n<br />
	LEFT JOIN<br />
		(SELECT COUNT(comments.id) AS count, comments.news_id FROM comments GROUP BY comments.news_id) AS c<br />
			ON n.id = c.news_id<br />
				INNER JOIN<br />
					users AS u<br />
						ON n.user_id = u.id<br />
							WHERE u.id = 1;<br />
</code></p>
<p><strong>5) SELECT COMMENTS FOR ANY PARTICULAR NEWS (HERE, news_id =1)</strong></p>
<p><code><br />
SELECT c.* FROM comments AS c<br />
	INNER JOIN<br />
		news AS n<br />
			ON c.news_id = n.id<br />
				WHERE c.news_id = 1;<br />
</code></p>
<p><strong>6) SELECT COMMENTS FOR ANY PARTICULAR NEWS (ALONG WITH USER INFORMATION) (HERE, news_id = 1)</strong></p>
<p><code><br />
SELECT c.*, u.firstname AS firstname, u.lastname AS lastname FROM comments AS c<br />
	INNER JOIN<br />
		news AS n<br />
			ON c.news_id = n.id<br />
				INNER JOIN<br />
					users AS u<br />
						ON c.user_id = u.id<br />
							WHERE c.news_id = 1;<br />
</code></p>
<p><strong>7) SELECT TAGS FOR ANY PARTICULAR NEWS (HERE, news_id = 1)</strong>	</p>
<p><code><br />
SELECT t.* FROM tags AS t<br />
	INNER JOIN<br />
		(SELECT tags_news.news_id AS news_id, tags_news.tags_id FROM tags_news WHERE tags_news.news_id = 1) AS tn<br />
			ON t.id = tn.tags_id;<br />
</code>			</p>
<p><strong>8) SELECT NEWS BY TAG NAME (HERE, tag = &#8216;nepal&#8217;)</strong></p>
<p><code><br />
SELECT n.*, t.name AS tag_name, t.slug AS tag_slug FROM news AS n<br />
	INNER JOIN<br />
		tags_news as tn<br />
			ON n.id = tn.news_id<br />
				INNER JOIN tags AS t<br />
					ON tn.tags_id = t.id<br />
						WHERE t.slug = 'nepal';<br />
</code>			</p>
<p><strong>9) SELECT NEWS BY TAG NAME (ALONG WITH COMMENTS COUNT) (HERE, tag = &#8216;nepal&#8217;)	</strong>		</p>
<p><code><br />
SELECT n.*, ifnull(c.count,0) AS comment, t.name AS tag_name, t.slug AS tag_slug, t.id AS tag_id FROM news AS n<br />
	INNER JOIN<br />
		tags_news AS tn<br />
			ON (n.id = tn.news_id)<br />
				INNER JOIN tags AS t<br />
					ON (tn.tags_id = t.id)<br />
						LEFT JOIN<br />
							(SELECT COUNT(comments.id) AS count, comments.news_id FROM comments<br />
								GROUP BY comments.news_id) AS c<br />
									ON n.id = c.news_id<br />
										WHERE t.slug = 'nepal'<br />
											ORDER BY n.created_date DESC;<br />
</code></p>
<p><strong>10) SELECT TAG CLOUD</strong>		</p>
<p><code><br />
SELECT t . * , IFNULL( tq.count, 0 ) AS count<br />
	FROM tags AS t<br />
		LEFT JOIN (<br />
			SELECT COUNT( tags_news.id ) AS count, tags_news.tags_id<br />
				FROM tags_news<br />
					GROUP BY tags_news.tags_id<br />
						) AS tq ON t.id = tq.tags_id<br />
							ORDER BY t.name ASC<br />
								LIMIT 15;<br />
</code><br />
Hope this helps. And thanks for reading.  </p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=779&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/' rel='bookmark' title='Permanent Link: Magento: Join, filter, select and sort attributes, fields and tables'>Magento: Join, filter, select and sort attributes, fields and tables</a></li>
<li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento: How to filter product collection using 2 or more category filters?</title>
		<link>http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/</link>
		<comments>http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 12:44:51 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[find_in_set]]></category>
		<category><![CDATA[product]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=475</guid>
		<description><![CDATA[Suppose, you have a product collection and you want to filter it by category. Suppose, you want to filter it by more than one category. You can use addCategoryFilter if you have only one category. But, what if you want to filter by more than one category? Category ids are stored for product in a [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-get-category-name-and-url-from-product/' rel='bookmark' title='Permanent Link: Magento: Get category name and url from product'>Magento: Get category name and url from product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-sub-categories-and-product-count/' rel='bookmark' title='Permanent Link: Magento: Get sub categories and product count'>Magento: Get sub categories and product count</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-search-or-filter-by-multiselect-attribute-in-admin-grid/' rel='bookmark' title='Permanent Link: Magento: How to search or filter by multiselect attribute in admin grid?'>Magento: How to search or filter by multiselect attribute in admin grid?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-1-4-no-products-displayed-in-category-listing/' rel='bookmark' title='Permanent Link: Magento 1.4: No products displayed in category listing'>Magento 1.4: No products displayed in category listing</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-product-collection-by-type/' rel='bookmark' title='Permanent Link: Magento: Get Product Collection by Type'>Magento: Get Product Collection by Type</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Suppose, you have a product collection and you want to filter it by category. Suppose, you want to filter it by more than one category. You can use addCategoryFilter if you have only one category. But, what if you want to filter by more than one category?</p>
<p>Category ids are stored for product in a comma separated way. So, to filter product collection by more than one category, you have to use:<br />
<strong>addAttributeToFilter(&#8216;category_ids&#8217;,array(&#8216;finset&#8217;=>$categoryIds));</strong></p>
<p><span id="more-475"></span></p>
<p><strong>$categoryIds</strong> can be a single category id or comma separated category ids.</p>
<p>The following code filters product collection by two category ids (36 and 37).</p>
<pre class="brush: php; title: ; notranslate">
 $_productCollection = Mage::getResourceModel('reports/product_collection')
    -&gt;addAttributeToSelect('*')
    -&gt;addAttributeToFilter('category_ids',array('finset'=&gt;'36,37'));
</pre>
<p>finset does so&#8230; when we use finset, the mysql function <strong>find_in_set</strong> is used in the sql query by Magento.</p>
<p>mysql function find_in_set:</p>
<p><strong>FIND_IN_SET()</strong> looks for the first occurrence of a string within another string containing comma-separated values.</p>
<p>SELECT FIND_IN_SET(&#8216;b&#8217;,'a,b,c,d&#8217;);  // result = 2</p>
<p>Cheers!</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=475&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-get-category-name-and-url-from-product/' rel='bookmark' title='Permanent Link: Magento: Get category name and url from product'>Magento: Get category name and url from product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-sub-categories-and-product-count/' rel='bookmark' title='Permanent Link: Magento: Get sub categories and product count'>Magento: Get sub categories and product count</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-search-or-filter-by-multiselect-attribute-in-admin-grid/' rel='bookmark' title='Permanent Link: Magento: How to search or filter by multiselect attribute in admin grid?'>Magento: How to search or filter by multiselect attribute in admin grid?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-1-4-no-products-displayed-in-category-listing/' rel='bookmark' title='Permanent Link: Magento 1.4: No products displayed in category listing'>Magento 1.4: No products displayed in category listing</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-product-collection-by-type/' rel='bookmark' title='Permanent Link: Magento: Get Product Collection by Type'>Magento: Get Product Collection by Type</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Magento: Adding attribute from MySql setup file</title>
		<link>http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/</link>
		<comments>http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 08:16:36 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=379</guid>
		<description><![CDATA[You can add attribute from Admin Panel -> Catalog -> Attributes -> Manage Attributes. You can also add attributes from mysql setup file of your module. MySql setup file is present inside &#8220;YourModule/sql/yourmodule_setup&#8221; directory. In the following example, the version of my module is 0.1.0.  I have added attribute for product. I have added a [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-adding-category-attributes/' rel='bookmark' title='Permanent Link: Magento: Adding category attributes'>Magento: Adding category attributes</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-get-attribute-name-and-value/' rel='bookmark' title='Permanent Link: Magento: How to get attribute name and value?'>Magento: How to get attribute name and value?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-upload-file/' rel='bookmark' title='Permanent Link: Magento: How to upload file?'>Magento: How to upload file?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>You can add attribute from <strong>Admin Panel -> Catalog -> Attributes -> Manage Attributes</strong>.</p>
<p>You can also add attributes from mysql setup file of your module. MySql setup file is present inside &#8220;<strong>YourModule/sql/yourmodule_setup</strong>&#8221; directory.</p>
<p><span id="more-379"></span></p>
<p>In the following example, the version of my module is <strong>0.1.0</strong>.  I have added attribute for product. I have added a new Attribute Group called &#8220;<strong>Special Attributes</strong>&#8221; and then I have assigned the new attribute called &#8220;<strong>testing_attribute</strong>&#8221; into the &#8220;<strong>Special Attribute</strong>&#8221; group.</p>
<pre class="brush: php; title: ; notranslate">

// file mysql4-install-0.1.0.php

&lt;?php

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer-&gt;startSetup();
/**
 * Adding Different Attributes
 */

// adding attribute group
$setup-&gt;addAttributeGroup('catalog_product', 'Default', 'Special Attributes', 1000);

// the attribute added will be displayed under the group/tab Special Attributes in product edit page
$setup-&gt;addAttribute('catalog_product', 'testing_attribute', array(
	'group'     	=&gt; 'Special Attributes',
	'input'         =&gt; 'text',
    'type'          =&gt; 'text',
    'label'         =&gt; 'Testing',
	'backend'       =&gt; '',
	'visible'       =&gt; 1,
	'required'		=&gt; 0,
	'user_defined' =&gt; 1,
	'searchable' =&gt; 1,
	'filterable' =&gt; 0,
	'comparable'	=&gt; 1,
	'visible_on_front' =&gt; 1,
	'visible_in_advanced_search'  =&gt; 0,
	'is_html_allowed_on_front' =&gt; 0,
    'global'        =&gt; Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

$installer-&gt;endSetup();
</pre>
<p>Be careful on <strong>input </strong>and <strong>type</strong>. Input means the input type of the attribute. And type means the input type in database.</p>
<p>For textfield it will be:<br />
<code>'input' => 'text',<br />
'type' => 'text',</code></p>
<p>For textarea it will be:<br />
<code>'input' => 'textarea',<br />
'type' => 'text',</code></p>
<p>For date field it will be:<br />
<code>'input' => 'date',<br />
'type' => 'datetime',</code></p>
<p>For select list it will be:<br />
<code>'input' => 'select',<br />
'type' => 'text',</code></p>
<p>Here is the sample code to add datetime attribute. Please note that the <strong>type </strong>for date should be <code>datetime </code>and <strong>backend </strong>should be <code>eav/entity_attribute_backend_datetime</code>.</p>
<pre class="brush: php; title: ; notranslate">
$setup-&gt;addAttribute('catalog_product', 'delivery_date', array(
	'group'     	=&gt; 'Special Attributes',
	'input'         =&gt; 'date',
    'type'          =&gt; 'datetime',
    'label'         =&gt; 'Delivery',
	'backend'		=&gt; &quot;eav/entity_attribute_backend_datetime&quot;,
	'visible'       =&gt; 1,
	'required'		=&gt; 0,
	'user_defined' =&gt; 1,
	'searchable' =&gt; 1,
	'filterable' =&gt; 0,
	'comparable'	=&gt; 0,
	'visible_on_front' =&gt; 1,
	'visible_in_advanced_search'  =&gt; 0,
	'is_html_allowed_on_front' =&gt; 0,
    'global'        =&gt; Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
</pre>
<h3>Adding custom options to dropdown attribute through setup file</h3>
<p>You can also add custom options to dropdown attribute, like there is in <strong>manufacturer </strong>or <strong>color </strong>attribute.</p>
<p>Here is a sample code for this purpose:-</p>
<pre class="brush: php; title: ; notranslate">
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer-&gt;startSetup();						

$setup-&gt;addAttribute('catalog_product', 'test_attribute', array(
			 'label'             =&gt; 'Test',
			 'type'              =&gt; 'varchar',
			 'input'             =&gt; 'select',
			 'backend'           =&gt; 'eav/entity_attribute_backend_array',
			 'frontend'          =&gt; '',
			 'source'            =&gt; 'yourmodule/source_option',
			 'global'            =&gt; Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
			 'visible'           =&gt; true,
			 'required'          =&gt; true,
			 'user_defined'      =&gt; true,
			 'searchable'        =&gt; false,
			 'filterable'        =&gt; false,
			 'comparable'        =&gt; false,
			 'option'            =&gt; array (
											'value' =&gt; array('optionone' =&gt; array('Sony'),
															 'optiontwo' =&gt; array('Samsung'),
															 'optionthree' =&gt; array('Apple'),
														)
										),
			 'visible_on_front'  =&gt; false,
			 'visible_in_advanced_search' =&gt; false,
			 'unique'            =&gt; false
));

$installer-&gt;endSetup();
</pre>
<p>In the code above, we have added a dropdown attribute named &#8216;<strong>Test</strong>&#8216;. Three options (<strong>Sony</strong>, <strong>Samsung</strong>, and <strong>Apple</strong>) are added to this attribute. </p>
<p><strong>Note</strong>:- In the <strong>source </strong>value, you can see <strong>yourmodule/source_option</strong>. This means, you just need to create a file <strong>YourModule/Model/Source/Option.php</strong> with the following code:-</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

class YourNamespace_YourModule_Model_Source_Option extends Mage_Eav_Model_Entity_Attribute_Source_Table
{

}
</pre>
<h3>Following are the allowed parameters for attributes</h3>
<p>:</p>
<p>(see <strong>Mage_Eav_Model_Entity_Setup::addAttribute</strong>)</p>
<pre class="brush: php; title: ; notranslate">

$data = array(
            'entity_type_id'            =&gt; $entityTypeId,
            'attribute_code'            =&gt; $code,
            'backend_model'             =&gt; $this-&gt;_getValue($attr, 'backend', ''),
            'backend_type'              =&gt; $this-&gt;_getValue($attr, 'type', 'varchar'),
            'backend_table'             =&gt; $this-&gt;_getValue($attr, 'table', ''),
            'frontend_model'            =&gt; $this-&gt;_getValue($attr, 'frontend', ''),
            'frontend_input'            =&gt; $this-&gt;_getValue($attr, 'input', 'text'),
            'frontend_input_renderer'   =&gt; $this-&gt;_getValue($attr, 'input_renderer', ''),
            'frontend_label'            =&gt; $this-&gt;_getValue($attr, 'label', ''),
            'frontend_class'            =&gt; $this-&gt;_getValue($attr, 'frontend_class', ''),
            'source_model'              =&gt; $this-&gt;_getValue($attr, 'source', ''),
            'is_global'                 =&gt; $this-&gt;_getValue($attr, 'global', 1),
            'is_visible'                =&gt; $this-&gt;_getValue($attr, 'visible', 1),
            'is_required'               =&gt; $this-&gt;_getValue($attr, 'required', 1),
            'is_user_defined'           =&gt; $this-&gt;_getValue($attr, 'user_defined', 0),
            'default_value'             =&gt; $this-&gt;_getValue($attr, 'default', ''),
            'is_searchable'             =&gt; $this-&gt;_getValue($attr, 'searchable', 0),
            'is_filterable'             =&gt; $this-&gt;_getValue($attr, 'filterable', 0),
            'is_comparable'             =&gt; $this-&gt;_getValue($attr, 'comparable', 0),
            'is_visible_on_front'       =&gt; $this-&gt;_getValue($attr, 'visible_on_front', 0),
            'is_html_allowed_on_front'  =&gt; $this-&gt;_getValue($attr, 'is_html_allowed_on_front', 0),
            'is_visible_in_advanced_search'
                                        =&gt; $this-&gt;_getValue($attr, 'visible_in_advanced_search', 0),
            'is_used_for_price_rules'   =&gt; $this-&gt;_getValue($attr, 'used_for_price_rules', 1),
            'is_filterable_in_search'   =&gt; $this-&gt;_getValue($attr, 'filterable_in_search', 0),
            'used_in_product_listing'   =&gt; $this-&gt;_getValue($attr, 'used_in_product_listing', 0),
            'used_for_sort_by'          =&gt; $this-&gt;_getValue($attr, 'used_for_sort_by', 0),
            'is_unique'                 =&gt; $this-&gt;_getValue($attr, 'unique', 0),
            'apply_to'                  =&gt; $this-&gt;_getValue($attr, 'apply_to', ''),
            'is_configurable'           =&gt; $this-&gt;_getValue($attr, 'is_configurable', 1),
            'note'                      =&gt; $this-&gt;_getValue($attr, 'note', ''),
            'position'                  =&gt; $this-&gt;_getValue($attr, 'position', 0),
        );
</pre>
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=379&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-adding-category-attributes/' rel='bookmark' title='Permanent Link: Magento: Adding category attributes'>Magento: Adding category attributes</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-get-attribute-name-and-value/' rel='bookmark' title='Permanent Link: Magento: How to get attribute name and value?'>Magento: How to get attribute name and value?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-upload-file/' rel='bookmark' title='Permanent Link: Magento: How to upload file?'>Magento: How to upload file?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Magento: Upgrading mysql setup of a module</title>
		<link>http://blog.chapagain.com.np/magento-upgrading-mysql-setup-of-a-module/</link>
		<comments>http://blog.chapagain.com.np/magento-upgrading-mysql-setup-of-a-module/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 08:30:53 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=363</guid>
		<description><![CDATA[Suppose, you have a module called MyModule. Its version is 0.1.0. Now, you want to do some database changes for the module. You have the mysql setup file (mysql install file) mysql4-install-0.1.0.php in MyModule/sql/mymodule_setup folder of your module. You don&#8217;t need to make direct changes to database. You can upgrade your module to make your [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/' rel='bookmark' title='Permanent Link: Magento: Adding attribute from MySql setup file'>Magento: Adding attribute from MySql setup file</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-title-keywords-and-description-in-your-module/' rel='bookmark' title='Permanent Link: Magento: Set title, keywords and description in your module'>Magento: Set title, keywords and description in your module</a></li>
<li><a href='http://blog.chapagain.com.np/magento-access-denied-in-admin-of-custom-module/' rel='bookmark' title='Permanent Link: Magento: Access denied in admin of custom module'>Magento: Access denied in admin of custom module</a></li>
<li><a href='http://blog.chapagain.com.np/magento-read-write-xml/' rel='bookmark' title='Permanent Link: Magento: Read Write XML'>Magento: Read Write XML</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-installation-problem/' rel='bookmark' title='Permanent Link: MySQL Installation Problem'>MySQL Installation Problem</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Suppose, you have a module called <strong>MyModule</strong>. Its version is <strong>0.1.0</strong>. Now, you want to do some database changes for the module. You have the mysql setup file (mysql install file) <strong>mysql4-install-0.1.0.php</strong> in <strong>MyModule/sql/mymodule_setup</strong> folder of your module.</p>
<p>You don&#8217;t need to make direct changes to database. You can upgrade your module to make your necessary database changes. To do so,</p>
<p><span id="more-363"></span></p>
<p>1) You need to create a new mysql upgrade file inside <strong>MyModule/sql/mymodule_setup</strong> folder.</p>
<p>Let us suppose that you are going to change the version of your module from 0.1.0 to 0.1.1.</p>
<p>The mysql upgrade file name should be <strong>mysql4-upgrade-0.1.0-0.1.1.php</strong></p>
<p>The upgrade format is like <em>mysql4-upgrade-CURRENT_VERSION-UPGRADED_VERSION.php</em></p>
<p>2) Write necessary sql statements in the newly added mysql upgrade file.</p>
<p>3) You have to change the version in <strong>MyModule/etc/config.xml</strong> as well.</p>
<p>Change the version like <strong><version>0.1.1</version></strong>. 0.1.1 is the new version for our module.</p>
<p>4) Reload your site. And you are done!</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=363&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/' rel='bookmark' title='Permanent Link: Magento: Adding attribute from MySql setup file'>Magento: Adding attribute from MySql setup file</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-title-keywords-and-description-in-your-module/' rel='bookmark' title='Permanent Link: Magento: Set title, keywords and description in your module'>Magento: Set title, keywords and description in your module</a></li>
<li><a href='http://blog.chapagain.com.np/magento-access-denied-in-admin-of-custom-module/' rel='bookmark' title='Permanent Link: Magento: Access denied in admin of custom module'>Magento: Access denied in admin of custom module</a></li>
<li><a href='http://blog.chapagain.com.np/magento-read-write-xml/' rel='bookmark' title='Permanent Link: Magento: Read Write XML'>Magento: Read Write XML</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-installation-problem/' rel='bookmark' title='Permanent Link: MySQL Installation Problem'>MySQL Installation Problem</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-upgrading-mysql-setup-of-a-module/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Very simple add, edit, delete, display in PHP</title>
		<link>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/</link>
		<comments>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 08:03:11 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[edit]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[register]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2008/03/05/very-simple-add-edit-delete-display-in-php/</guid>
		<description><![CDATA[Before I had posted an article to add, edit, delete, and display contents. I had also included sessions there. There was the facility to login and register users too. But i got feedback that it was a bit complex for novice users of PHP (users who have just started PHPing). It was a kind of [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/' rel='bookmark' title='Permanent Link: Add, edit, delete, login, register in PHP :: A simple and complete tutorial'>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-select-insert-update-and-delete-data/' rel='bookmark' title='Permanent Link: Magento: How to select, insert, update, and delete data?'>Magento: How to select, insert, update, and delete data?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-remove-extension-from-magentoconnect/' rel='bookmark' title='Permanent Link: Magento: How to delete / remove extension from MagentoConnect?'>Magento: How to delete / remove extension from MagentoConnect?</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Before I had posted an article to <a href="http://blog.chapagain.com.np/2007/12/08/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/">add, edit, delete, and display contents</a>. I had also included sessions there. There was the facility to login and register users too.</p>
<p>But i got feedback that it was a bit complex for novice users of PHP (users who have just started PHPing). It was a kind of full-fledge system with PHP, MySQL and session.</p>
<p><span id="more-44"></span></p>
<p>So in this article, I have simplified the same functionality of the above tutorial. I have not used session in this case. If you want tutorial about session, login, and register then you can refer to my previous article (the link which is provided above).</p>
<p><strong>Files included in this tutorial/code:</strong></p>
<p>users.sql = This contains sql queries to make MySQL database and table</p>
<p>config.php = contains the database connection code (this file is included in all the php pages with the include() function)</p>
<p>index.php = contains the display part (displaying data from database)</p>
<p>add.html = contains form to add data</p>
<p>add.php = contains php code to add data</p>
<p>edit.php = contains php code to edit data</p>
<p>delete.php = contains php code to delete data</p>
<p><strong>Download full source code: <a href="http://chapagain.googlecode.com/files/crud-simple.zip" title="Create, read, update, delete in php and mysql">Create, read, update, delete in php and mysql</a></strong></p>
<p>Cheers,</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=44&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/' rel='bookmark' title='Permanent Link: Add, edit, delete, login, register in PHP :: A simple and complete tutorial'>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-select-insert-update-and-delete-data/' rel='bookmark' title='Permanent Link: Magento: How to select, insert, update, and delete data?'>Magento: How to select, insert, update, and delete data?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-remove-extension-from-magentoconnect/' rel='bookmark' title='Permanent Link: Magento: How to delete / remove extension from MagentoConnect?'>Magento: How to delete / remove extension from MagentoConnect?</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Fun with strings in PHP (Part 1)</title>
		<link>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/</link>
		<comments>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 04:48:39 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[concatenate]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2007/12/09/fun-with-strings-in-php-part-1/</guid>
		<description><![CDATA[Problem: Concatenate and fetch data from two fields of database and then break it again. Solution: Posted below. The description is included in the code. You have to make a mysql database. The database part is as under: PHP code below: I have not used any loop (for, while, foreach, etc.) here to make the [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/page-refresh-in-php/' rel='bookmark' title='Permanent Link: Page refresh in PHP'>Page refresh in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-get-working-site-path-and-directory-name-in-php/' rel='bookmark' title='Permanent Link: How to get working site path and directory name in php?'>How to get working site path and directory name in php?</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Concatenate and fetch data from two fields of database and then break it again.</p>
<p><strong>Solution:</strong></p>
<p><span id="more-36"></span></p>
<p>Posted below.</p>
<p>The description is included in the code.</p>
<p>You have to make a mysql database. The database part is as under:</p>
<pre class="brush: sql; title: ; notranslate">
create database test;

use test;

create table user(id int(9) not null auto_increment, first_name varchar(20), last_name varchar(20), primary key(id));

insert into user(first_name, last_name) values (&quot;mukesh&quot;,&quot;chapagain&quot;);
</pre>
<p>PHP code below:</p>
<p>I have not used any loop (for, while, foreach, etc.)  here to make the code simple. :-)</p>
<pre class="brush: php; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Fun with strings&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php

// in my configuration, i am running mysql in localhost, my database username is 'root' and i don't have any database password
// i have a table called 'user' in the database 'test'

// connecting to the database server
mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;);

// connecting to the database
mysql_select_db(&quot;test&quot;);

// selecting data from table named 'user' where id = 1
$result = mysql_query(&quot;select concat(first_name,',',last_name) as name from user where id = '1'&quot;);

// fetching the result and assigning it to certain variables
while ($row = mysql_fetch_assoc($result))
{
$name = $row['name'];
echo &quot;$name &lt;br/&gt;&quot;; // you will get the result as first_name,last_name
}
$newName = explode(&quot;,&quot;,$name); // this will make an array with each name as values

//print_r($newName);

// print the first name as
echo &quot;First Name: &quot; . $newName[0] . &quot;&lt;br/&gt;&quot;;

// print the second name as
echo &quot;Second Name: &quot; . $newName[1] . &quot;&lt;br/&gt;&quot;;

// you can find about how many elements/items are there with the commas
$count = count($newName);
echo &quot;Count: $count &lt;br/&gt;&quot;;

// there is a function called 'implode' which will join array elements with a string
$newNameTwo = implode(&quot; &quot;,$newName); // this will print the names with spaces in between... before the names were separated with comma
echo &quot;$newNameTwo &lt;br/&gt;&quot;;

?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Happy PHPing!</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=36&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/page-refresh-in-php/' rel='bookmark' title='Permanent Link: Page refresh in PHP'>Page refresh in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-get-working-site-path-and-directory-name-in-php/' rel='bookmark' title='Permanent Link: How to get working site path and directory name in php?'>How to get working site path and directory name in php?</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</title>
		<link>http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/</link>
		<comments>http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 06:44:19 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[register]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2007/12/08/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/</guid>
		<description><![CDATA[Hello everyone! here is a simple and complete tutorial to add, edit, delete, login, and register in PHP with MySQL database. The description is present in the code.. in comments :D I hope those comments are sufficient to describe the code. The database part is in the sql file named &#8216;database.sql&#8217;. I have attached the [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/' rel='bookmark' title='Permanent Link: Very simple add, edit, delete, display in PHP'>Very simple add, edit, delete, display in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-stock-quote-data-from-yahoo-finance-complete-code-and-tutorial/' rel='bookmark' title='Permanent Link: PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)'>PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/creating-dynamic-table-in-php/' rel='bookmark' title='Permanent Link: Creating dynamic table in PHP : Easy and Simple tutorial'>Creating dynamic table in PHP : Easy and Simple tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hello everyone! here is a simple and complete tutorial to add, edit, delete, login, and register in PHP with MySQL database.</p>
<p>The description is present in the code.. in comments :D I hope those comments are sufficient to describe the code. The database part is in the sql file named &#8216;database.sql&#8217;.</p>
<p><span id="more-31"></span></p>
<p>I have attached the code with this post. Download it and enjoy PHPing&#8230;</p>
<p><strong>Download full source code: <a href="http://chapagain.googlecode.com/files/crud-complete.zip" title="PHP code for add,edit,delete,login, and register">PHP code for add,edit,delete,login, and register</a></strong></p>
<p>Cheers,</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=31&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/' rel='bookmark' title='Permanent Link: Very simple add, edit, delete, display in PHP'>Very simple add, edit, delete, display in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-stock-quote-data-from-yahoo-finance-complete-code-and-tutorial/' rel='bookmark' title='Permanent Link: PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)'>PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/creating-dynamic-table-in-php/' rel='bookmark' title='Permanent Link: Creating dynamic table in PHP : Easy and Simple tutorial'>Creating dynamic table in PHP : Easy and Simple tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
