<?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>Mind Tree &#187; MySQL</title>
	<atom:link href="http://hurricanesoftwares.edublogs.org/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://hurricanesoftwares.edublogs.org</link>
	<description>Technology made simple.</description>
	<lastBuildDate>Thu, 26 Jun 2008 09:19:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting-Up a Relational Database in MySQL</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/06/18/setting-up-a-relational-database-in-mysql/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/06/18/setting-up-a-relational-database-in-mysql/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 11:17:13 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.hurricanesoftwares.com/?p=168</guid>
		<description><![CDATA[Relational Database Design is one of the most powerful ways to  ensure data integrity and a great way to kick-off any project. Very  often the first thing developers do when starting a new project, or  stub-project, is to design the database. This way the structure of the  application is already in [...]]]></description>
			<content:encoded><![CDATA[<p>Relational Database Design is one of the most powerful ways to  ensure data integrity and a great way to kick-off any project. Very  often the first thing developers do when starting a new project, or  stub-project, is to design the database. This way the structure of the  application is already in place and we just have to fill in the pieces  with some server-side code. I&#8217;ve found when adding relational  constraints to your database design you add in a very powerful error  reporting tool that will let you know during the development process  that you have allowed something to happen that shouldn&#8217;t have. In this  article, I go through, step by step, showing how to set up a simple  relational database and discuss the benefits that are enjoyed.</p>
<p>Let&#8217;s take a step back and describe what a relational database looks  like. In any normal database design there are fields in one table that  reference another table. For example, a books table might have a field  labeled author_id which is meant to come from a table named authors.  Creating hard-coded relations solidifies these associations and  actually returns a MySQL error if violated.</p>
<p>As I hinted in the opening I have found this to be invaluable during  the development and testing process as MySQL will immediately let me  know that I have made a glaring error that otherwise may not have been  noticed until after the service has launched. At that point the data  could be irreparably corrupt and forced to start from scratch.</p>
<p>So let&#8217;s get right to it. For the purposes of this article, I&#8217;m  going to pretend I&#8217;m creating a simple Books and Authors website with a  simple 2-table setup. The first step is to create our tables.</p>
<div>
<ol>
<li> CREATE TABLE `library`.`books` (</li>
<li>`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,</li>
<li>`name` VARCHAR( 150 ) NOT NULL ,</li>
<li>`author_id` INT UNSIGNED NOT NULL ,</li>
<li>PRIMARY KEY ( `id` ) ,</li>
<li>INDEX ( `author_id` )</li>
<li>) ENGINE = InnoDB</li>
</ol>
</div>
<p><textarea cols="50" rows="5" name="code"> CREATE TABLE `library`.`books` (  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,  `name` VARCHAR( 150 ) NOT NULL ,  `author_id` INT UNSIGNED NOT NULL ,  PRIMARY KEY ( `id` ) ,  INDEX ( `author_id` )  ) ENGINE = InnoDB</textarea></p>
<div>
<ol>
<li>CREATE TABLE `authors` (</li>
<li> `id` int(10) unsigned NOT NULL auto_increment,</li>
<li> `name` varchar(50) collate utf8_bin NOT NULL,</li>
<li> PRIMARY KEY  (`id`)</li>
<li>) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin</li>
</ol>
</div>
<p><textarea cols="50" rows="4" name="code2">CREATE TABLE `authors` (    `id` int(10) unsigned NOT NULL auto_increment,    `name` varchar(50) collate utf8_bin NOT NULL,    PRIMARY KEY  (`id`)  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin</textarea></p>
<p><img src="http://www.mikebernat.com/images/relational/relation-1.png" border="0" alt="Relational Database - 1" width="536" height="150" /></p>
<p>Nothing too fancy here. Couple things to notice:</p>
<ol>
<li>Each table MUST be using the InnoDB storage engine. InnoDB is  currently the only main-stream storage engine offered by MySQL to  support relational design. More on this in my article: <a href="http://mikebernat.com/blog/blog/MySQL_-_InnoDB_vs_MyISAM">MyISAM vs InnoDB</a></li>
<li>The `author_id` field in the `books` table MUST be indexed and the same datatype as the `id` field in `authors`.</li>
</ol>
<p>The next step is to set up the relations. Open the `authors` table  and take a look at the view. Under the table there should be a link  titled &#8216;Relation View&#8217; &#8211; Click it.</p>
<p><img src="http://www.mikebernat.com/images/relational/relation-2.png" border="0" alt="Relational Database - 2" width="515" height="192" /></p>
<p>phpMyAdmin has a great gui for setting up relations and actions. If  the `author_id` row below doesn&#8217;t look like mine, make sure you have it  indexed.</p>
<p><img src="http://www.mikebernat.com/images/relational/relation-3.png" border="0" alt="Relational Database - 3" width="516" height="189" /></p>
<p>Here, I&#8217;ve setup a link on the `books` table and the `author_id`  field. This will enforce the fact that any value inserted in this field  MUST be present in the `authors.id` table as well. But what about these  other settings?</p>
<p><strong>ON DELETE</strong>:</p>
<ul>
<li><strong>CASCADE</strong>:
<ul>
<li>This means if an author is deleted from the authors table, all of his books will also be automatically deleted.</li>
<li>This option is great to keep your data clean and reduce the number of delete quieries required when deleting an author.</li>
</ul>
</li>
<li><strong>SET NULL</strong>:
<ul>
<li>Instead of deleting the book record when an author is deleted, books.author_id is set to NULL, effectively orphaning the book.</li>
<li>This feature is great if you want to be able to keep the books and  come back at a later time to reassign them. Otherwise, without this  feature, the books would still be referencing an author_id that doesn&#8217;t  exist.</li>
<li>Note: If you try to set this option and phpMyAdmin tells you to  check your datatypes, make sure the field is allowing null values.</li>
</ul>
</li>
<li><strong>NO ACTION</strong>:
<ul>
<li>When a delete query is issued on an author that has books, MySQL will not allow this and return a Foreign_Key Constraint error.</li>
<li>It could be nice to identify this and re-word it to let the user  know that if they would like to delete this author they need to  re-assign his books or delete them all-together.</li>
<li>Note: If you use this option please remember to re-word the MySQL error to something the user can easily understand.</li>
</ul>
</li>
<li><strong>RESTRICT</strong>:
<ul>
<li>Same as NO ACTION</li>
<li>From <a href="http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html" target="_blank">MySQL Manual</a>: Some database systems have deferred checks, and              NO ACTION is a deferred check. In MySQL,              foreign key constraints are checked immediately, so              NO ACTION and RESTRICT              are the same.</li>
</ul>
</li>
</ul>
<p><strong>ON UPDATE</strong>:</p>
<ul>
<li>For the most part the options described above are going to act in  the same manner they did for ON DELETE as they will with ON UPDATE.  I&#8217;ll just run through some examples real quick.</li>
<li><strong>CASCADE</strong>:
<ul>
<li>If, for some reason, an author&#8217;s id gets updated than CASCADE will  update all his corresponding books with the new value. Extremely handy.</li>
</ul>
</li>
<li><strong>SET NULL</strong>
<ul>
<li>Same as CASCADE except instead of updating it with the new value,  it will set it to null. I&#8217;m sure there is a perfectly good use for this  but I haven&#8217;t run into it yet. If anyone can enlighten me please do <img src='http://hurricanesoftwares.edublogs.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
</li>
<li><strong>NO ACTION / RESTRICT</strong>:
<ul>
<li>Same as ON DELETE, will throw an error if you try to update an  author_id. I&#8217;m also having trouble finding a real-world example of when  this could be useful</li>
</ul>
</li>
</ul>
<p>Once we have our simple relational database configured try to add a  book with an author_id that doesn&#8217;t exist. MySQL should give you an  error like this:</p>
<p>Cannot add or update a child row: a foreign key constraint fails  (`library/books`, CONSTRAINT `books_ibfk_1` FOREIGN KEY (`author_id`)  REFERENCES `authors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F06%2F18%2Fsetting-up-a-relational-database-in-mysql%2F';
  addthis_title  = 'Setting-Up+a+Relational+Database+in+MySQL';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/06/18/setting-up-a-relational-database-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Securing Your Input Forms From MySQL Injection Attacks</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/06/12/php-securing-your-input-forms-from-mysql-injection-attacks/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/06/12/php-securing-your-input-forms-from-mysql-injection-attacks/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 09:48:22 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.hurricanesoftwares.com/?p=166</guid>
		<description><![CDATA[Every website has ‘em. Forms. Places for users to enter data into your website. Whether it be a search box, a “Contact Us” form, or variables in the website address, at some point in the flow of your script these suckers are going to touch your database. Oh, that’s no problem — We’ll just take [...]]]></description>
			<content:encoded><![CDATA[<p>Every website has ‘em. Forms. Places for users to enter data into your website. Whether it be a search box, a “Contact Us” form, or variables in the website address, at some point in the flow of your script these suckers are going to touch your database. Oh, that’s no problem — We’ll just take what they type in and run a query in MySQL on it!</p>
<p>WHOA, there! Are you sure you want to do that? Any input from a user should be treated like a nuclear fuel rod. You can handle it, but you’ve got to make sure you do it right. You wouldn’t just pick it up with your bare hands, would you?</p>
<p><strong>Why? Just what are MySQL Injection attacks anyway?</strong></p>
<p>Lets say your database has a table inside called ‘tbl_Users’. Inside ‘tbl_Users’ are a list of your users, which all have usernames, passwords, first names, last names, addresses, etc. If these users are presented with a login box somewhere on your site, your php user verification query might be something like this:</p>
<p><strong><em>SELECT * FROM `tbl_Users` WHERE `username`=&#8217;&#8221;.$_POST['username'].”‘ AND `password`=’”.md5($_POST['password']).”‘”</em></strong>The problem is that unscrupulous users (read: bad ones) could enter this into your form:</p>
<p> </p>
<p>username: no_onepassword: &#8216; OR &#8221;=&#8221;Which would make your query look something like this:</p>
<p>SELECT * FROM `tbl_Users` WHERE `username`=&#8217;no_one&#8217; AND `password`=&#8221; OR &#8221;=&#8221;Which, if you read that correctly, would allow that user access to whatever it was you wanted hidden by logging them in. There are a multitude of other ways this can be dangerous, but this is by far the easiest example. Even more unscrupulous users (read: the real jackasses) could send in multiple queries including DELETE queries.</p>
<p>In which case, when you wake up the morning after the attack you are most likely to be heard saying:”Hey, where did all my users go?” </p>
<p>Wow. Okay so I’ve got a friend… and his website isn’t secure. What can I do to help him out?</p>
<p>The good news is that with a few easy precautions, your “friend’s” website will be pretty secure against these types of attacks. I say pretty secure because there is no way to prevent every attack. We can only do our best to increase security to a point to take every realistic precaution to prevent these attacks.</p>
<p><strong>#1: Escape your variables!</strong></p>
<p>Using the php function ‘mysql_real_escape_string’ you can “escape” the single quote character from user input. This is probably the easiest method to prevent MySQL injection attacks. It works by adding a backslash (”\”) before each quote that the user enters into their input. So, to use our example from before:</p>
<p>username: hey&#8217;therebecomes</p>
<p>username: hey\&#8217;thereThis effectively stops MySQL injection in its tracks since it not only escapes the single quote (”‘”) character but also all other characters that the baddies can use to hijack your queries.</p>
<p>If you’ve got an array of data coming in, you can use this neat function that I found on the PHP mysql_real_escape_string page (code by “brian dot folts at gmail dot com”). It escapes all of the values in your array with ease.</p>
<p>To escape an array, use this function:</p>
<p><strong><em>function mysql_real_escape_array($t){<br />
return array_map(”mysql_real_escape_string”,$t);<br />
}</em></strong></p>
<p>Then you can call that function easily by passing your array to it:</p>
<p><strong><em>$your_array = mysql_real_escape_array($your_array);</em></strong></p>
<p><strong>#2: Check the variable type of your input.</strong></p>
<p>This is done by using the php functions “is_numeric()“, “is_string()“, “is_float()“, and “is_int()” to determine if the input the user is sending in is the same type that you were asking for. It’s not perfect, but if you were asking for a number and they sent in a word you know to discard it straight away and return an error thereby entirely avoiding any change of a MySQL injection attack.</p>
<p><strong>#3: Always use proper MySQL syntax, including “`” and “‘” characters.</strong></p>
<p>If your queries look something like this:</p>
<p><strong><em>SELECT * FROM tbl_Users WHERE username=$value; </em></strong>Rewrite it so that it looks more like this:</p>
<p><strong><em>$value = mysql_real_escape_string($value);mysql_query(SELECT * FROM `tbl_Users` WHERE `username`=&#8217;&#8221;.$value.&#8221;&#8216;&#8221;); </em></strong>Proper MySQL syntax requires that all table and field names are surrounded by the reverse apostraphe (”`”) and values surrounded with single quotes / apostraphe (”‘”).</p>
<p>I hope this gives you a better indication of what you can do to help secure your websites. Keep in mind that this is in no way a complete list. Be ever vigilant in your efforts to prevent attacks of any kind on your code. Leave a comment or two if this helped you at all or if you have different suggestions on how to secure your code from injection attacks!</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F06%2F12%2Fphp-securing-your-input-forms-from-mysql-injection-attacks%2F';
  addthis_title  = 'PHP%3A+Securing+Your+Input+Forms+From+MySQL+Injection+Attacks';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/06/12/php-securing-your-input-forms-from-mysql-injection-attacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database Normalization and Table structures</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/06/03/database-normalization-and-table-structures/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/06/03/database-normalization-and-table-structures/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 10:21:53 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[Design Principles]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.hurricanesoftwares.com/?p=165</guid>
		<description><![CDATA[Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal Form), 3NF (Third Normal Form) and BCNF (Boyce-Codd Normal Form). There are others but they are rarely if ever [...]]]></description>
			<content:encoded><![CDATA[<p>Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal Form), 3NF (Third Normal Form) and BCNF (Boyce-Codd Normal Form). There are others but they are rarely if ever used. A database is said to be Normalised if it is in 3NF (or ideally in BCNF). These steps are descibed as follows:<br />
<br /><strong><em>Note:<span class="Apple-converted-space"> </span></em><em>When attribute is used we are speaking of a field in the table</em></strong></p>
<p><strong>1NF</strong><br />To put a database in 1N</p>
<ul>
<li>ensure that all attributes (columns) are atomic (which means that any single field should only have a value for ONE thing).</li>
</ul>
<p><span style="text-decoration: underline">Examples:</span></p>
<div><img src="http://bytes.com/images/howtos/normalization_table2.gif" border="0" alt="" width="455" height="59" /></div>
<p>In a database a table on Customers would have an address attribute. The address is made up of Company Name, Address Line1, Address Line2, Address Line3, City, Postcode. There are 6 values to this address and as such each should have it&#8217;s own field (column).</p>
<div><img src="http://bytes.com/images/howtos/normalization_table1.gif" border="0" alt="" width="480" height="65" /></div>
<p>If your company sold furniture a table on products could have a description attribute. If for example that attribute was &#8216;Beech Desk 120w x 75h x 50d&#8217;. Ideally this would be broken down into a number attributes like &#8216;Colour&#8217;, &#8216;Type&#8217;, &#8216;Width&#8217;, &#8216;Height&#8217; and &#8216;Depth&#8217;. The reason for this is it would allow you to seach the database for all Desks, for all pieces of Beech furniture, for all desks with a width of 120 etc.</p>
<ul>
<li>Create a separate table for each set of related data and Identify each set of related data with a primary key</li>
</ul>
<p><span style="text-decoration: underline"><strong>Example:</strong></span></p>
<div><img src="http://bytes.com/images/howtos/normalization_tblDiagram1.gif" border="0" alt="" width="447" height="94" /></div>
<p>In a general Invoicing table you would have a separate table for Customers, Orders, Products, Invoices and you would probably need tables for OrderDetails and InvoiceDetails as well. Each of these tables must have their own primary key. Each of these tables except for customers would have a foreign key reference to the primary key of another table. (<em>See Relationships below</em>)</p>
<ul>
<li>Do not use multiple fields in a single table to store similar data</li>
</ul>
<p><span style="text-decoration: underline"><strong>Example:</strong></span><span class="Apple-converted-space"> </span><br />(<em>Underlined fields are Primary Keys and Italicised fields are Foreign Keys</em>)</p>
<p>In a customer order you could have more than one product. That is the customer has ordered more than one item. If you tried to put all of this in one table as {<span style="text-decoration: underline">OrderID</span>,<span class="Apple-converted-space"> </span><em>CustomerID</em>, OrderDate, Product1, Product2, Product3} what would happen if the customer ordered more than 3 products. There would also be implications for querying the kind or quantiy of products ordered by a customer. Therefore these product fields don&#8217;t belong in the order table which is why we would have an OrderDetails table which would have a foreign key refernce to the Orders table {<span style="text-decoration: underline">OrderDetailsID</span>,<span class="Apple-converted-space"> </span><em>OrderID</em>,<span class="Apple-converted-space"> </span><em>ProductID</em>, Quantity}. Using productID as a foreign key to the product table means you don&#8217;t have to identify the product attributes here. This also allows you to enter a quantity figure for the product ordered.</p>
<p><strong><span style="text-decoration: underline"><em>Relationships:</em></span></strong></p>
<p>All tables should have a 1 to 1 or 1 to many relationship. This means for example that 1 customer can have 1 or many orders and 1 order can have 1 or many details.<span class="Apple-converted-space"> </span></p>
<div><img src="http://bytes.com/images/howtos/normalization_tblDiagram2.gif" border="0" alt="" /></div>
<p>Therefore Orders table would have a foreign key reference to the Customer table primary key {<span style="text-decoration: underline">OrderID</span>,<span class="Apple-converted-space"> </span><em>CustomerID</em>, OrderDate} and the OrderDetails table would have a foreign key reference to the Order table primary key {<span style="text-decoration: underline">OrderDetailsID</span>,<span class="Apple-converted-space"> </span><em>OrderID</em>,<span class="Apple-converted-space"> </span><em>ProductID</em>, Quantity}. This table also contains a foreign key reference to the Products table. As a product is likely to be ordered more than once there is a many to 1 relationship between the OrderDetails and the Products table.</p>
<div><img src="http://bytes.com/images/howtos/normalization_tblDiagram3.gif" border="0" alt="" /></div>
<p>If any tables have a many to many relationship this must be broken out using a JOIN table. For example, Customers can have many Suppliers and Suppliers can supply to many Customers. This is known as a many to many relationship. You would need to create a JOIN table that would have a primary key made up of a foreign key reference to the Customers table and a foreign key reference to the suppliers table. Therefore the SuppliersPerCustomer table would be {<span style="text-decoration: underline"><em>SupplierID</em></span>,<span style="text-decoration: underline"><em>CustomerID</em></span>}. Now the Suppliers table will have a 1 to many relationship with the SuppliersPerCustomer table and the Customers table will also have a 1 to many relationship with the SuppliersPerCustomer table.</p>
<p><strong>2NF</strong></p>
<p>The database must meet all the requirements of the 1NF.<span class="Apple-converted-space"> </span></p>
<p>In addition, records should not depend on anything other than a table&#8217;s primary key (a primary key can be made up of more than one field, only if absolutely necessary like in a JOIN table).</p>
<p><span style="text-decoration: underline"><strong>Example:</strong></span></p>
<p>A customers address is needed by the Customers table, but also by the Orders, and Invoices tables. Instead of storing the customer&#8217;s address as a separate entry in each of these tables, store it in one place, either in the Customers table or in a separate Addresses table.</p>
<p><strong>3NF</strong></p>
<p>The database must meet all the requirements of the 1NF and 2NF.</p>
<p>The third normal form requires that all columns in a relational table are dependent only upon the primary key. A more formal definition is:</p>
<ul>
<li>A relational table is in third normal form (3NF) if it is already in 2NF and every non-key column is non transitively dependent upon its primary key.</li>
</ul>
<p>In other words, all nonkey attributes are functionally dependent only upon the primary key. All 3NF really means is that all fields (attributes) should be dependent on the tables primary key. If they are not they should be put in their own table. This means that every attribute unless it is a primary or foreign key must be DIRECTLY dependent on the Primary Key of this table and not on some other column.</p>
<p><strong><span style="text-decoration: underline">Example:</span><br /></strong><br />The Customer table contains information such as address, city, postcode imagine it also contained a column called shipping cost. The value of shipping cost changes in relation to which city the products are being delivered to, and therefore is not directly dependent on the customer even though the cost might not change per customer, but it is dependent on the city that the customer is in. Therefore we would need to create another separate table to hold the information about cities and shipping costs.</p>
<p><strong>BCNF</strong></p>
<p>A relation is in Boyce-Codd Normal Form (BCNF) if every determinant is a candidate key. BCNF is very similar to 3NF but deals with dependencies within the primary keys. BCNF in it&#8217;s simplist terms just says don&#8217;t have a primary key made up of more than one field unless it is a join table to disperse a many to many relationship and only contains the two primary keys of the tables it is joining.<span class="Apple-converted-space"> </span></p>
<p>Most relations that are in 3NF are also in BCNF. It only happens that a relation which is in 3NF is not in BCNF when the primary key in a table is made up of more than one field and the other columns are not dependent on both fields but only on one or the other.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F06%2F03%2Fdatabase-normalization-and-table-structures%2F';
  addthis_title  = 'Database+Normalization+and+Table+structures';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/06/03/database-normalization-and-table-structures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free PHP Scripts, Source Code and Tutorial Website List</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/03/11/free-php-scripts-source-code-and-tutorial-website-list/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/03/11/free-php-scripts-source-code-and-tutorial-website-list/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 09:25:35 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://hurricanesoftwares.edublogs.org/2008/03/11/free-php-scripts-source-code-and-tutorial-website-list/</guid>
		<description><![CDATA[Following are the websites list who provide free php scripts. You can find lots of information about PHP as well as free code samples, code galleries, and free scripts for download at these and other sites. There may be some premium php scripts which may come for a price but overall the list is good [...]]]></description>
			<content:encoded><![CDATA[<p>Following are the websites list who provide free php scripts. You can find lots of information about PHP as well as free code samples, code galleries, and free scripts for download at these and other sites. There may be some premium php scripts which may come for a price but overall the list is good enough.</p>
<p><a href="http://www.scripts.com/php-scripts/" target="_blank">http://www.scripts.com/php-scripts/</a><br />
<a href="http://www.best-php-scripts.com/" target="_blank">http://www.best-php-scripts.com/</a><br />
<a href="http://gscripts.net/" target="_blank">http://gscripts.net/</a><br />
<a href="http://www.phpjunkyard.com/" target="_blank">http://www.phpjunkyard.com/</a><br />
<a href="http://www.free-php.net/" target="_blank">http://www.free-php.net/</a><br />
<a href="http://coding.phpground.net/" target="_blank">http://coding.phpground.net/</a><br />
<a href="http://www.atomicphp.com/" target="_blank">http://www.atomicphp.com/</a><br />
<a href="http://www.thefreecountry.com/php/index.shtml" target="_blank">http://www.thefreecountry.com/php/index.shtml</a><br />
<a href="http://www.phpbuilder.com/snippet/" target="_blank">http://www.phpbuilder.com/snippet/</a><br />
<a href="http://phpwizard.net/" target="_blank">http://phpwizard.net/</a><br />
<a href="http://www.devshed.com/Server_Side/PHP" target="_blank">http://www.devshed.com/Server_Side/PHP</a><br />
<a href="http://www.phpclasses.org/" target="_blank">http://www.phpclasses.org/</a><br />
<a href="http://px.sklar.com/" target="_blank">http://px.sklar.com/</a><br />
<a href="http://zend.com/codex.php" target="_blank">http://zend.com/codex.php</a><br />
<a href="http://www.weberdev.com/" target="_blank">http://www.weberdev.com/</a><br />
<a href="http://www.hotscripts.com/PHP/" target="_blank">http://www.hotscripts.com/PHP/</a><br />
<a href="http://www.phpresourceindex.com/" target="_blank">http://www.phpresourceindex.com/</a></p>
<p>I would be adding more to the list soon&#8230;.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F03%2F11%2Ffree-php-scripts-source-code-and-tutorial-website-list%2F';
  addthis_title  = 'Free+PHP+Scripts%2C+Source+Code+and+Tutorial+Website+List';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/03/11/free-php-scripts-source-code-and-tutorial-website-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing XML using PHP : Good example</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php-good-example/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php-good-example/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 13:20:56 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php-good-example/</guid>
		<description><![CDATA[The following example illustrates how to use an external entity reference handler to include and parse other documents, as well as how PIs can be processed, and a way of determining &#34;trust&#34; for PIs containing code.
Consider the following XML&#8217;s
&#60; ?xml version=&#8217;1.0&#8242;?&#62;
&#60; !DOCTYPE chapter SYSTEM &#34;/just/a/test.dtd&#34; [
&#60;!ENTITY plainEntity &#34;FOO entity&#34;&#62;
&#60; !ENTITY systemEntity SYSTEM &#34;xmltest2.xml&#34;&#62;
]&#62;
&#60;chapter&#62;
&#160;&#60;title&#62;Title &#38;plainEntity;&#60;/title&#62;
&#160;&#60;para&#62;
&#160; &#60;informaltable&#62;
&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example illustrates how to use an external entity reference handler to include and parse other documents, as well as how PIs can be processed, and a way of determining &quot;trust&quot; for PIs containing code.</p>
<p><strong>Consider the following XML&#8217;s</strong></p>
<p>&lt; ?xml version=&#8217;1.0&#8242;?&gt;<br />
&lt; !DOCTYPE chapter SYSTEM &quot;/just/a/test.dtd&quot; [<br />
&lt;!ENTITY plainEntity &quot;FOO entity&quot;&gt;<br />
&lt; !ENTITY systemEntity SYSTEM &quot;xmltest2.xml&quot;&gt;<br />
]&gt;<br />
&lt;chapter&gt;<br />
&nbsp;&lt;title&gt;Title &amp;plainEntity;&lt;/title&gt;<br />
&nbsp;&lt;para&gt;<br />
&nbsp; &lt;informaltable&gt;<br />
&nbsp;&nbsp; &lt;tgroup cols=&quot;3&quot;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;tbody&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;row&gt;&lt;entry&gt;a1&lt;/entry&gt;&lt;entry morerows=&quot;1&quot;&gt;b1&lt;/entry&gt;&lt;entry&gt;c1&lt;/entry&gt;&lt;/row&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;row&gt;&lt;entry&gt;a2&lt;/entry&gt;&lt;entry&gt;c2&lt;/entry&gt;&lt;/row&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;row&gt;&lt;entry&gt;a3&lt;/entry&gt;&lt;entry&gt;b3&lt;/entry&gt;&lt;entry&gt;c3&lt;/entry&gt;&lt;/row&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/tbody&gt;<br />
&nbsp;&nbsp; &lt;/tgroup&gt;<br />
&nbsp; &lt;/informaltable&gt;<br />
&nbsp;&lt;/para&gt;<br />
&nbsp;&amp;systemEntity;<br />
&nbsp;&lt;section id=&quot;about&quot;&gt;<br />
&nbsp; &lt;title&gt;About this Document&lt;/title&gt;<br />
&nbsp; &lt;para&gt;<br />
&nbsp;&nbsp; &lt;!&#8211; this is a comment &#8211;&gt;<br />
&nbsp;&nbsp; &lt; ?php echo &#8216;Hi!&nbsp; This is PHP version &#8216; . phpversion(); ?&gt;<br />
&nbsp; &lt;/para&gt;<br />
&nbsp;&lt;/section&gt;<br />
&lt;/chapter&gt;</p>
<p>&lt;?xml version=&quot;1.0&quot;?&gt;<br />
&lt;!DOCTYPE foo [<br />
&lt;!ENTITY testEnt &quot;test entity&quot;&gt;<br />
]&gt;<br />
&lt;foo&gt;<br />
&lt;element attrib=&quot;value&quot;/&gt;<br />
&amp;testEnt;<br />
&lt;?php echo &quot;This is some more PHP code being executed.&quot;; ?&gt;<br />
&lt;/foo&gt;</p>
<p>
<strong>The following code shows how we can parse the above XML file using PHP</strong></p>
<p>&lt; ?php<br />
$file = &quot;xmltest.xml&quot;;</p>
<p>function trustedFile($file) <br />
{<br />
&nbsp;&nbsp;&nbsp; // only trust local files owned by ourselves<br />
&nbsp;&nbsp;&nbsp; if (!eregi(&quot;^([a-z]+)://&quot;, $file) <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; fileowner($file) == getmyuid()) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; return false;<br />
}</p>
<p>function startElement($parser, $name, $attribs) <br />
{<br />
&nbsp;&nbsp;&nbsp; echo &quot;&amp;lt;&lt;font color=\&quot;#0000cc\&quot;&gt;$name&quot;;<br />
&nbsp;&nbsp;&nbsp; if (count($attribs)) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach ($attribs as $k =&gt; $v) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot; &lt;font color=\&quot;#009900\&quot;&gt;$k&lt;/font&gt;=\&quot;&lt;font color=\&quot;#990000\&quot;&gt;$v&lt;/font&gt;\&quot;&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; echo &quot;&amp;gt;&quot;;<br />
}</p>
<p>function endElement($parser, $name) <br />
{<br />
&nbsp;&nbsp;&nbsp; echo &quot;&amp;lt;/&lt;font color=\&quot;#0000cc\&quot;&gt;$name&lt;/font&gt;&amp;gt;&quot;;<br />
}</p>
<p>function characterData($parser, $data) <br />
{<br />
&nbsp;&nbsp;&nbsp; echo &quot;&lt;b&gt;$data&lt;/b&gt;&quot;;<br />
}</p>
<p>function PIHandler($parser, $target, $data) <br />
{<br />
&nbsp;&nbsp;&nbsp; switch (strtolower($target)) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case &quot;php&quot;:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; global $parser_file;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If the parsed document is &quot;trusted&quot;, we say it is safe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // to execute PHP code inside it.&nbsp; If not, display the code<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // instead.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (trustedFile($parser_file[$parser])) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eval($data);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Untrusted PHP code: &lt;i&gt;%s&lt;/i&gt;&quot;, <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($data));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />
&nbsp;&nbsp;&nbsp; }<br />
}</p>
<p>function defaultHandler($parser, $data) <br />
{<br />
&nbsp;&nbsp;&nbsp; if (substr($data, 0, 1) == &quot;&amp;&quot; &amp;&amp; substr($data, -1, 1) == &quot;;&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&#8217;&lt;font color=&quot;#aa00aa&quot;&gt;%s&lt;/font&gt;&#8217;, <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($data));<br />
&nbsp;&nbsp;&nbsp; } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&#8217;&lt;font size=&quot;-1&quot;&gt;%s&lt;/font&gt;&#8217;, <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($data));<br />
&nbsp;&nbsp;&nbsp; }<br />
}</p>
<p>function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $publicId) {<br />
&nbsp;&nbsp;&nbsp; if ($systemId) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!list($parser, $fp) = new_xml_parser($systemId)) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Could not open entity %s at %s\n&quot;, $openEntityNames,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $systemId);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ($data = fread($fp, 4096)) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!xml_parse($parser, $data, feof($fp))) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;XML error: %s at line %d while parsing entity %s\n&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xml_error_string(xml_get_error_code($parser)),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xml_get_current_line_number($parser), $openEntityNames);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xml_parser_free($parser);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xml_parser_free($parser);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; return false;<br />
}</p>
<p>function new_xml_parser($file) <br />
{<br />
&nbsp;&nbsp;&nbsp; global $parser_file;</p>
<p>&nbsp;&nbsp;&nbsp; $xml_parser = xml_parser_create();<br />
&nbsp;&nbsp;&nbsp; xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1);<br />
&nbsp;&nbsp;&nbsp; xml_set_element_handler($xml_parser, &quot;startElement&quot;, &quot;endElement&quot;);<br />
&nbsp;&nbsp;&nbsp; xml_set_character_data_handler($xml_parser, &quot;characterData&quot;);<br />
&nbsp;&nbsp;&nbsp; xml_set_processing_instruction_handler($xml_parser, &quot;PIHandler&quot;);<br />
&nbsp;&nbsp;&nbsp; xml_set_default_handler($xml_parser, &quot;defaultHandler&quot;);<br />
&nbsp;&nbsp;&nbsp; xml_set_external_entity_ref_handler($xml_parser, &quot;externalEntityRefHandler&quot;);<br />
&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; if (!($fp = @fopen($file, &quot;r&quot;))) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; if (!is_array($parser_file)) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; settype($parser_file, &quot;array&quot;);<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; $parser_file[$xml_parser] = $file;<br />
&nbsp;&nbsp;&nbsp; return array($xml_parser, $fp);<br />
}</p>
<p>if (!(list($xml_parser, $fp) = new_xml_parser($file))) {<br />
&nbsp;&nbsp;&nbsp; die(&quot;could not open XML input&quot;);<br />
}</p>
<p>echo &quot;&lt;pre&gt;&quot;;<br />
while ($data = fread($fp, 4096)) {<br />
&nbsp;&nbsp;&nbsp; if (!xml_parse($xml_parser, $data, feof($fp))) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; die(sprintf(&quot;XML error: %s at line %d\n&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xml_error_string(xml_get_error_code($xml_parser)),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xml_get_current_line_number($xml_parser)));<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
echo &quot;&lt;/pre&gt;&quot;;<br />
echo &quot;parse complete\n&quot;;<br />
xml_parser_free($xml_parser);</p>
<p>?&gt;</p>
<p>I hope this will help. Your comments are welcome.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F03%2F06%2Fparsing-xml-using-php-good-example%2F';
  addthis_title  = 'Parsing+XML+using+PHP+%3A+Good+example';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php-good-example/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Parsing XML using PHP</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 13:09:37 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php/</guid>
		<description><![CDATA[Load an XML file as data using PHP

By handling mime-types and using browser detection, CodeHelp has already shown how to export XML using a PHP script. PHP can also receive XML as input &#8211; using the XML parser:
if (!($fp=@fopen(&#34;./contactsbare.xml&#34;, &#34;r&#34;)))
&#160;&#160;&#160;&#160;&#160;&#160;&#160; die (&#34;Couldn&#8217;t open XML.&#34;);
$usercount=0;
$userdata=array();
$state=&#8221;;
if (!($xml_parser = xml_parser_create()))
&#160;&#160;&#160;&#160;&#160;&#160;&#160; die(&#34;Couldn&#8217;t create parser.&#34;);
Each XML file can have it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<h1>Load an XML file as data using PHP</h1>
<p>
By handling mime-types and using browser detection, CodeHelp has already shown how to export XML using a PHP script. PHP can also receive XML as input &#8211; using the XML parser:</p>
<p>if (!($fp=@fopen(&quot;./contactsbare.xml&quot;, &quot;r&quot;)))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; die (&quot;Couldn&#8217;t open XML.&quot;);<br />
$usercount=0;<br />
$userdata=array();<br />
$state=&#8221;;<br />
if (!($xml_parser = xml_parser_create()))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; die(&quot;Couldn&#8217;t create parser.&quot;);</p>
<p>Each XML file can have it&#8217;s own DTD or structure. The PHP file using the XML parser must be tailored to one particular structure or DTD &#8211; it will then be able to read all files that are valid under that DTD. This example will use an over-simplified contacts format for XML &#8211; you will need to adapt the details of the tags (or nodes) for your own DTD. To follow the construction of the XML parser, load the example XML file into another window using the link in the Navigation Bar. (If the file doesn&#8217;t open in a new window in your browser, right click the link and choose Open in a New Window.) Multiple contacts can be specified by repeating the CONTACT tag and the PHP file therefore needs to keep track of the number of contacts used in this example. In the above code, $usercount is set to zero ready to hold the number of contacts found. $userdata will later be filled with data for each contact and $state is used to keep track of which node the parser is dealing with for each contact.</p>
<p>The PHP XML parser now needs two functions to be declared, one to handle the element data and one to handle the character data within the elements. This is where you need to change the code to reflect your own XML files &#8211; change the element and attribute names. I&#8217;ll start with the Element Handler. This is in two parts, a function to detect the start of real data and a function to detect when an element comes to an end &#8211; in this case to register when more than one contact is specified. Each function is called once for each node &#8211; use a switch statement to decide what action to take depending on which node is being processed. The parser will take care of the $name and $attrib variables.</p>
<p>function startElementHandler ($parser,$name,$attrib){<br />
global $usercount;<br />
global $userdata;<br />
global $state;</p>
<p>switch ($name) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case $name==&quot;NAME&quot; : {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $userdata[$usercount][&quot;first&quot;] = $attrib[&quot;FIRST&quot;];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $userdata[$usercount][&quot;last&quot;] = $attrib[&quot;LAST&quot;];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $userdata[$usercount][&quot;nick&quot;] = $attrib[&quot;NICK&quot;];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $userdata[$usercount][&quot;title&quot;] = $attrib[&quot;TITLE&quot;];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
}</p>
<p>function endElementHandler ($parser,$name){<br />
global $usercount;<br />
global $userdata;<br />
global $state;<br />
$state=&#8221;;<br />
if($name==&quot;CONTACT&quot;) {$usercount++;}<br />
}</p>
<p>The function &quot;startElementHandler()&quot; has been abbreviated here by removing the other case $name==&quot;&quot; : {} statements, the full file will be looked at later.</p>
<p>Next, we need the character handler:</p>
<p>function characterDataHandler ($parser, $data) {<br />
global $usercount;<br />
global $userdata;<br />
global $state;<br />
if (!$state) {return;}<br />
if ($state==&quot;COMPANY&quot;) { $userdata[$usercount][&quot;bcompany&quot;] = $data;}<br />
if ($state==&quot;GENDER&quot;) { $userdata[$usercount][&quot;gender&quot;] = $data;}<br />
}</p>
<p>Finally, tell the parser which functions to use, read the data from the opened file and parse the contents.</p>
<p>xml_set_element_handler($xml_parser,&quot;startElementHandler&quot;,&quot;endElementHandler&quot;);<br />
xml_set_character_data_handler( $xml_parser, &quot;characterDataHandler&quot;);</p>
<p>while( $data = fread($fp, 4096)){<br />
if(!xml_parse($xml_parser, $data, feof($fp))) {<br />
break;}}<br />
xml_parser_free($xml_parser);</p>
<p>The data from the XML file is now held in $userdata and can be accessed using a standard PHP loop:</p>
<p>for ($i=0;$i&lt;$usercount; $i++) {<br />
echo &quot;Name: &quot;.$userdata[$i][&quot;title&quot;].&quot; &quot;.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ucfirst($userdata[$i][&quot;first&quot;]).&quot; &quot;. ucfirst($userdata[$i][&quot;last&quot;]);<br />
}</p>
<p>&nbsp;</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F03%2F06%2Fparsing-xml-using-php%2F';
  addthis_title  = 'Parsing+XML+using+PHP';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/03/06/parsing-xml-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All about Extensible Markup Language (XML)</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/03/06/all-about-extensible-markup-language-xml/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/03/06/all-about-extensible-markup-language-xml/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 11:12:45 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://hurricanesoftwares.edublogs.org/2008/03/06/all-about-extensible-markup-language-xml/</guid>
		<description><![CDATA[Extensible Markup Language (XML) is a general-purpose specification for creating custom markup languages. It is classified as an extensible language because it allows its users to define their own elements. Its primary purpose is to facilitate the sharing of structured data across different information systems, particularly via the Internet, and it is used both to [...]]]></description>
			<content:encoded><![CDATA[<p>Extensible Markup Language (XML) is a general-purpose specification for creating custom markup languages. It is classified as an extensible language because it allows its users to define their own elements. Its primary purpose is to facilitate the sharing of structured data across different information systems, particularly via the Internet, and it is used both to encode documents and to serialize data.</p>
<p>well-formedness is required, XML is a generic framework for storing any amount of text or any data whose structure can be represented as a tree. The only indispensable syntactical requirement is that the document has exactly one root element (alternatively called the document element). This means that the text must be enclosed between a root start-tag and a corresponding end-tag. The following is a &quot;well-formed&quot; XML document:</p>
<p>&lt;book&gt;This is a book&#8230;. &lt;/book&gt;</p>
<p>The root element can be preceded by an optional XML declaration. This element states what version of XML is in use (normally 1.0); it may also contain information about character encoding and external dependencies.</p>
<p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</p>
<p>Here is an example of a structured XML document:</p>
<p>&lt;recipe name=&quot;bread&quot; prep_time=&quot;5 mins&quot; cook_time=&quot;3 hours&quot;&gt;<br />
&nbsp;&nbsp; &lt;title&gt;Basic bread&lt;/title&gt;<br />
&nbsp;&nbsp; &lt;ingredient amount=&quot;3&quot; unit=&quot;cups&quot;&gt;Flour&lt;/ingredient&gt;<br />
&nbsp;&nbsp; &lt;ingredient amount=&quot;0.25&quot; unit=&quot;ounce&quot;&gt;Yeast&lt;/ingredient&gt;<br />
&nbsp;&nbsp; &lt;ingredient amount=&quot;1.5&quot; unit=&quot;cups&quot; state=&quot;warm&quot;&gt;Water&lt;/ingredient&gt;<br />
&nbsp;&nbsp; &lt;ingredient amount=&quot;1&quot; unit=&quot;teaspoon&quot;&gt;Salt&lt;/ingredient&gt;<br />
&nbsp;&nbsp; &lt;instructions&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;step&gt;Mix all ingredients together.&lt;/step&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;step&gt;Knead thoroughly.&lt;/step&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;step&gt;Cover with a cloth, and leave for one hour in warm room.&lt;/step&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;step&gt;Knead again.&lt;/step&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;step&gt;Place in a bread baking tin.&lt;/step&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;step&gt;Cover with a cloth, and leave for one hour in warm room.&lt;/step&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;step&gt;Bake in the oven at 350&deg;F for 30 minutes.&lt;/step&gt;<br />
&nbsp;&nbsp; &lt;/instructions&gt;<br />
&nbsp;&lt;/recipe&gt;</p>
<p><strong>Entity references</strong></p>
<p>An entity in XML is a named body of data, usually text. Entities are often used to represent single characters that cannot easily be entered on the keyboard; they are also used to represent pieces of standard (&quot;boilerplate&quot;) text that occur in many documents, especially if there is a need to allow such text to be changed in one place only.</p>
<p>Special characters can be represented either using entity references, or by means of numeric character references. An example of a numeric character reference is &quot;&#x20AC;&quot;, which refers to the Euro symbol by means of its Unicode codepoint in hexadecimal.</p>
<p>An entity reference is a placeholder that represents that entity. It consists of the entity&#8217;s name preceded by an ampersand (&quot;&amp;&quot;) and followed by a semicolon (&quot;;&quot;). XML has five predeclared entities:<br />
&amp;amp; &nbsp;&nbsp;&nbsp; &amp; &nbsp;&nbsp;&nbsp; ampersand<br />
&amp;lt; &nbsp;&nbsp;&nbsp; &lt; &nbsp;&nbsp;&nbsp; less than<br />
&amp;gt; &nbsp;&nbsp;&nbsp; &gt; &nbsp;&nbsp;&nbsp; greater than<br />
&amp;apos; &nbsp;&nbsp;&nbsp; &#8216; &nbsp;&nbsp;&nbsp; apostrophe<br />
&amp;quot; &nbsp;&nbsp;&nbsp; &quot; &nbsp;&nbsp;&nbsp; quotation mark</p>
<p>Here is an example using a predeclared XML entity to represent the ampersand in the name &quot;AT&amp;T&quot;:</p>
<p>&lt;company_name&gt;AT&amp;amp;T&lt;/company_name&gt;</p>
<p>Additional entities (beyond the predefined ones) can be declared in the document&#8217;s Document Type Definition (DTD). A basic example of doing so in a minimal internal DTD follows. Declared entities can describe single characters or pieces of text, and can reference each other.</p>
<p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />
&lt;!DOCTYPE example [<br />
&nbsp;&nbsp;&nbsp; &lt;!ENTITY copy &quot;&#xA9;&quot;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;!ENTITY copyright-notice &quot;Copyright &amp;copy; 2006, hurricanesoftwares.com&quot;&gt;<br />
]&gt;<br />
&lt;example&gt;<br />
&nbsp;&nbsp;&nbsp; &amp;copyright-notice;<br />
&lt;/example&gt;</p>
<p>When viewed in a suitable browser, the XML document above appears as:</p>
<p>&lt;example&gt; Copyright &copy; 2006, Hurricanesoftwares.com &lt;/example&gt;</p>
<p><strong>Numeric character references</strong></p>
<p>Numeric character references look like entity references, but instead of a name, they contain the &quot;#&quot; character followed by a number. The number (in decimal or &quot;x&quot;-prefixed hexadecimal) represents a Unicode code point. Unlike entity references, they are neither predeclared nor do they need to be declared in the document&#8217;s DTD. They have typically been used to represent characters that are not easily encodable, such as an Arabic character in a document produced on a European computer. The ampersand in the &quot;AT&amp;T&quot; example could also be escaped like this (decimal 38 and hexadecimal 26 both represent the Unicode code point for the &quot;&amp;&quot; character):</p>
<p>&lt;company_name&gt;AT&#38;T&lt;/company_name&gt;<br />
&lt;company_name&gt;AT&#x26;T&lt;/company_name&gt;</p>
<p><strong>Well-formed documents</strong></p>
<p>In XML, a well-formed document must conform to the following rules, among others:</p>
<p>&nbsp;&nbsp;&nbsp; * Non-empty elements are delimited by both a start-tag and an end-tag.<br />
&nbsp;&nbsp;&nbsp; * Empty elements may be marked with an empty-element (self-closing) tag, such as &lt;IAmEmpty /&gt;. This is equal to &lt;IAmEmpty&gt;&lt;/IAmEmpty&gt;.<br />
&nbsp;&nbsp;&nbsp; * All attribute values are quoted with either single (&#8217;) or double (&quot;) quotes. Single quotes close a single quote and double quotes close a double quote.<br />
&nbsp;&nbsp;&nbsp; * Tags may be nested but must not overlap. Each non-root element must be completely contained in another element.<br />
&nbsp;&nbsp;&nbsp; * The document complies with its declared character encoding. The encoding may be declared or implied externally, such as in &quot;Content-Type&quot; headers when a document is transported via HTTP, or internally, using explicit markup at the very beginning of the document. When no such declaration exists, a Unicode encoding is assumed, as defined by a Unicode Byte Order Mark before the document&#8217;s first character. If the mark does not exist, UTF-8 encoding is assumed.</p>
<p>Element names are case-sensitive. For example, the following is a well-formed matching pair:</p>
<p>&nbsp;&nbsp;&nbsp; &lt;Step&gt; &#8230; &lt;/Step&gt;</p>
<p>whereas this is not</p>
<p>&nbsp;&nbsp;&nbsp; &lt;Step&gt; &#8230; &lt;/step&gt;</p>
<p>By carefully choosing the names of the XML elements one may convey the meaning of the data in the markup. This increases human readability while retaining the rigor needed for software parsing.</p>
<p>Choosing meaningful names implies the semantics of elements and attributes to a human reader without reference to external documentation. However, this can lead to verbosity, which complicates authoring and increases file size.</p>
<p><strong>Automatic verification</strong></p>
<p>It is relatively simple to verify that a document is well-formed or validated XML, because the rules of well-formedness and validation of XML are designed for portability of tools. The idea is that any tool designed to work with XML files will be able to work with XML files written in any XML language (or XML application). One example of using an independent tool follows:</p>
<p>&nbsp;&nbsp;&nbsp; * load it into an XML-capable browser, such as Firefox or Internet Explorer<br />
&nbsp;&nbsp;&nbsp; * use a tool like xmlwf (usually bundled with expat)<br />
&nbsp;&nbsp;&nbsp; * parse the document, for instance in Ruby:</p>
<p>irb&gt; require &quot;rexml/document&quot;<br />
irb&gt; include REXML<br />
irb&gt; doc = Document.new(File.new(&quot;test.xml&quot;)).root</p>
<p><strong>Displaying XML on the web</strong></p>
<p>XML documents do not carry information about how to display the data. Without using CSS or XSL, a generic XML document is rendered as raw XML text by most web browsers. Some display it with &#8216;handles&#8217; (e.g. + and &#8211; signs in the margin) that allow parts of the structure to be expanded or collapsed with mouse-clicks.</p>
<p>In order to style the rendering in a browser with CSS, the XML document must include a reference to the stylesheet:</p>
<p>&lt;?xml-stylesheet type=&quot;text/css&quot; href=&quot;myStyleSheet.css&quot;?&gt;</p>
<p>Note that this is different from specifying such a stylesheet in HTML, which uses the &lt;link&gt; element.</p>
<p>Extensible Stylesheet Language (XSL) can be used to alter the format of XML data, either into HTML or other formats that are suitable for a browser to display.</p>
<p>To specify client-side XSL Transformation (XSLT), the following processing instruction is required in the XML:</p>
<p>&lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;myTransform.xslt&quot;?&gt;</p>
<p>Client-side XSLT is supported by many web browsers. Alternatively, one may use XSL to convert XML into a displayable format on the server rather than being dependent on the end-user&#8217;s browser capabilities. The end-user is not aware of what has gone on &#8216;behind the scenes&#8217;; all they see is well-formatted, displayable data.</p>
<p><strong>Processing XML files</strong></p>
<p>Three traditional techniques for processing XML files are:</p>
<p>&nbsp;&nbsp;&nbsp; * Using a programming language and the SAX API.<br />
&nbsp;&nbsp;&nbsp; * Using a programming language and the DOM API.<br />
&nbsp;&nbsp;&nbsp; * Using a transformation engine and a filter</p>
<p>More recent and emerging techniques for processing XML files are:</p>
<p>&nbsp;&nbsp;&nbsp; * Pull Parsing<br />
&nbsp;&nbsp;&nbsp; * Data binding</p>
<p><strong>Simple API for XML (SAX)</strong></p>
<p>SAX is a lexical, event-driven interface in which a document is read serially and its contents are reported as &quot;callbacks&quot; to various methods on a handler object of the user&#8217;s design. SAX is fast and efficient to implement, but difficult to use for extracting information at random from the XML, since it tends to burden the application author with keeping track of what part of the document is being processed. It is better suited to situations in which certain types of information are always handled the same way, no matter where they occur in the document.</p>
<p><strong>DOM</strong></p>
<p>DOM is an interface-oriented Application Programming Interface that allows for navigation of the entire document as if it were a tree of &quot;Node&quot; objects representing the document&#8217;s contents. A DOM document can be created by a parser, or can be generated manually by users (with limitations). Data types in DOM Nodes are abstract; implementations provide their own programming language-specific bindings. DOM implementations tend to be memory intensive, as they generally require the entire document to be loaded into memory and constructed as a tree of objects before access is allowed. DOM is supported in Java by several packages that usually come with the standard libraries. As the DOM specification is regulated by the World Wide Web Consortium, the main interfaces (Node, Document, etc.) are in the package org.w3c.dom.*, as well as some of the events and interfaces for other capabilities like serialization (output). The package com.sun.org.apache.xml.internal.serialize.* provides the serialization (output capacities) by implementing the appropriate interfaces, while the javax.xml.parsers.* package parses data to create DOM XML documents for manipulation.</p>
<p><strong>Transformation engines and filters</strong></p>
<p>A filter in the Extensible Stylesheet Language (XSL) family can transform an XML file for displaying or printing.</p>
<p>&nbsp;&nbsp;&nbsp; * XSL-FO is a declarative, XML-based page layout language. An XSL-FO processor can be used to convert an XSL-FO document into another non-XML format, such as PDF.<br />
&nbsp;&nbsp;&nbsp; * XSLT is a declarative, XML-based document transformation language. An XSLT processor can use an XSLT stylesheet as a guide for the conversion of the data tree represented by one XML document into another tree that can then be serialized as XML, HTML, plain text, or any other format supported by the processor.<br />
&nbsp;&nbsp;&nbsp; * XQuery is a W3C language for querying, constructing and transforming XML data.<br />
&nbsp;&nbsp;&nbsp; * XPath is a DOM-like node tree data model and path expression language for selecting data within XML documents. XSL-FO, XSLT and XQuery all make use of XPath. XPath also includes a useful function library.</p>
<p><strong>Pull parsing</strong></p>
<p>Pull parsing [6] treats the document as a series of items which are read in sequence using the Iterator design pattern. This allows for writing of recursive-descent parsers in which the structure of the code performing the parsing mirrors the structure of the XML being parsed, and intermediate parsed results can be used and accessed as local variables within the methods performing the parsing, or passed down (as method parameters) into lower-level methods, or returned (as method return values) to higher-level methods. Examples of pull parsers include StAX in the Java programming language, SimpleXML in PHP and System.Xml.XmlReader in .NET.</p>
<p>A pull parser creates an iterator that sequentially visits the various elements, attributes, and data in an XML document. Code which uses this &#8216;iterator&#8217; can test the current item (to tell, for example, whether it is a start or end element, or text), and inspect its attributes (local name, namespace, values of XML attributes, value of text, etc.), and can also move the iterator to the &#8216;next&#8217; item. The code can thus extract information from the document as it traverses it. The recursive-descent approach tends to lend itself to keeping data as typed local variables in the code doing the parsing, while SAX, for instance, typically requires a parser to manually maintain intermediate data within a stack of elements which are parent elements of the element being parsed. Pull-parsing code can be more straightforward to understand and maintain than SAX parsing code.</p>
<p><strong>Data binding</strong></p>
<p>Another form of XML Processing API is data binding, where XML data is made available as a custom, strongly typed programming language data structure, in contrast to the interface-oriented DOM. Example data binding systems include the Java Architecture for XML Binding (JAXB).</p>
<p><strong>Non-extractive XML Processing API</strong></p>
<p>Non-extractive XML Processing API is a new and emerging category of parsers that aim to overcome the fundamental limitations of DOM and SAX. The most representative is VTD-XML, which abolishes the object-oriented modeling of XML hierarchy and instead uses 64-bit Virtual Token Descriptors (encoding offsets, lengths, depths, and types) of XML tokens. VTD-XML&#8217;s approach enables a number of interesting features/enhancements, such as high performance, low memory usage, ASIC implementation, incremental update, and native XML indexing .</p>
<p><strong>Specific XML applications and editors</strong></p>
<p>The native file format of OpenOffice.org, AbiWord, and Apple&#8217;s iWork applications is XML. Some parts of Microsoft Office 2007 are also able to edit XML files with a user-supplied schema (but not a DTD), and Microsoft has released a file format compatibility kit for Office 2003 that allows previous versions of Office to save in the new XML based format. There are dozens of other XML editors available.</p>
<p><strong>Advantages of XML</strong></p>
<p>&nbsp;&nbsp;&nbsp; * It is text-based.<br />
&nbsp;&nbsp;&nbsp; * It supports Unicode, allowing almost any information in any written human language to be communicated.<br />
&nbsp;&nbsp;&nbsp; * It can represent common computer science data structures: records, lists and trees.<br />
&nbsp;&nbsp;&nbsp; * Its self-documenting format describes structure and field names as well as specific values.<br />
&nbsp;&nbsp;&nbsp; * The strict syntax and parsing requirements make the necessary parsing algorithms extremely simple, efficient, and consistent.<br />
&nbsp;&nbsp;&nbsp; * XML is heavily used as a format for document storage and processing, both online and offline.<br />
&nbsp;&nbsp;&nbsp; * It is based on international standards.<br />
&nbsp;&nbsp;&nbsp; * It can be updated incrementally.<br />
&nbsp;&nbsp;&nbsp; * It allows validation using schema languages such as XSD and Schematron, which makes effective unit-testing, firewalls, acceptance testing, contractual specification and software construction easier.<br />
&nbsp;&nbsp;&nbsp; * The hierarchical structure is suitable for most (but not all) types of documents.<br />
&nbsp;&nbsp;&nbsp; * It is platform-independent, thus relatively immune to changes in technology.<br />
&nbsp;&nbsp;&nbsp; * Forward and backward compatibility are relatively easy to maintain despite changes in DTD or Schema.<br />
&nbsp;&nbsp;&nbsp; * Its predecessor, SGML, has been in use since 1986, so there is extensive experience and software available.<br />
&nbsp;&nbsp;&nbsp; * An element fragment of a well-formed XML document is also a well-formed XML document.</p>
<p><strong>Disadvantages of XML</strong></p>
<p>&nbsp;&nbsp;&nbsp; * XML syntax is redundant or large relative to binary representations of similar data, especially with tabular data.<br />
&nbsp;&nbsp;&nbsp; * The redundancy may affect application efficiency through higher storage, transmission and processing costs.<br />
&nbsp;&nbsp;&nbsp; * XML syntax is verbose, especially for human readers, relative to other alternative &#8216;text-based&#8217; data transmission formats.<br />
&nbsp;&nbsp;&nbsp; * The hierarchical model for representation is limited in comparison to an object oriented graph.<br />
&nbsp;&nbsp;&nbsp; * Expressing overlapping (non-hierarchical) node relationships requires extra effort.<br />
&nbsp;&nbsp;&nbsp; * XML namespaces are problematic to use and namespace support can be difficult to correctly implement in an XML parser.<br />
&nbsp;&nbsp;&nbsp; * XML is commonly depicted as &quot;self-documenting&quot; but this depiction ignores critical ambiguities.<br />
&nbsp;&nbsp;&nbsp; * The distinction between content and attributes in XML seems unnatural to some and makes designing XML data structures harder</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F03%2F06%2Fall-about-extensible-markup-language-xml%2F';
  addthis_title  = 'All+about+Extensible+Markup+Language+%28XML%29';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/03/06/all-about-extensible-markup-language-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP Naming Conventions, Global Constants, Global Functions</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/03/03/cakephp-naming-conventions-global-constants-global-functions/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/03/03/cakephp-naming-conventions-global-constants-global-functions/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 06:41:43 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://hurricanesoftwares.edublogs.org/2008/03/03/cakephp-naming-conventions-global-constants-global-functions/</guid>
		<description><![CDATA[conﬁg (&#8217;ﬁle_name&#8217;) 
Global Functions
up (&#8217;string&#8217;) r (&#8217;search&#8217;, &#8216;replace&#8217;, &#8216;text&#8217;) pr (array) am (array, [array, array]) env (&#8217;HTTP_HEADER&#8217;)
cache (path, data, expires, [target])
Models
Class Name: singular, camel cased (LineItem, Person) File Name: singular, underscored (line_item.php, person.php) Table Name: plural, underscored (line_items, people)
Controllers
Class Name: plural, camel cased, ends in &#34;Controller&#34;
Views
Path: controller name, underscored (app/views/line_items/&#60;ﬁle&#62;, app/ views/people/&#60;ﬁle&#62;) File Name: action [...]]]></description>
			<content:encoded><![CDATA[<p>conﬁg (&#8217;ﬁle_name&#8217;) </p>
<p><strong>Global Functions</strong></p>
<p>up (&#8217;string&#8217;) r (&#8217;search&#8217;, &#8216;replace&#8217;, &#8216;text&#8217;) pr (array) am (array, [array, array]) env (&#8217;HTTP_HEADER&#8217;)</p>
<p>cache (path, data, expires, [target])</p>
<p><strong>Models</strong></p>
<p>Class Name: singular, camel cased (LineItem, Person) File Name: singular, underscored (line_item.php, person.php) Table Name: plural, underscored (line_items, people)</p>
<p><strong>Controllers</strong></p>
<p>Class Name: plural, camel cased, ends in &quot;Controller&quot;</p>
<p><strong>Views</strong></p>
<p>Path: controller name, underscored (app/views/line_items/&lt;ﬁle&gt;, app/ views/people/&lt;ﬁle&gt;) File Name: action name, lowercase (index.thtml, view.thtml)</p>
<p>uses (&#8217;ﬁle_name&#8217;) vendor (&#8217;ﬁle_name&#8217;) debug (&#8217;message&#8217;) a (element, [element, element]) aa (key, value, [key, value]) e (&#8217;message&#8217;) low (&#8217;STRING&#8217;)</p>
<p>(LineItemsController, People Controller)</p>
<p>File Name: plural, underscored</p>
<p>(line_items_controller.php, people_controller.php)</p>
<p>clearCache ([params, type, ext]) countdim (array)</p>
<p><strong>Model</strong></p>
<p>Properties $cacheQueries $data $displayField $id $name $primaryKey Methods $recursive $useDbConﬁg $useTable $validate $validationErrors $_tableInfo Association Properties $belongsTo $hasAndBelongsToMany $hasMany $hasOne</p>
<p><strong>Controller</strong></p>
<p>Properties $name $autoLayout $base $cacheAction $data $here $output $params $plugin $view $webroot Methods $action $autoRender $beforeFilter $components $helpers $layout $pageTitle $persistModel $uses $viewPath Properties $action $autoRender $controller $hasRendered $here $loaded $name $params $plugin $themeWeb $viewPath Methods</p>
<p><strong>View</strong></p>
<p>$autoLayout $base $ext $helpers $layout $models $pageTitle $parent $subDir $uses</p>
<p>bindModel (params) create ( ) delete (id, [cascade]) escapeField (ﬁeld) execute (data) exists ( ) ﬁeld (name, conditions, order) ﬁnd ([conditions, ﬁelds, order, recursive])</p>
<p>ﬁndAll ([conditions, ﬁelds, order, limit, page, recur...])</p>
<p>getLastInsertID ( ) getNumRows ( ) hasAny ([conditions]) hasField (name) invalidate (ﬁeld) invalidFields ([data]) isForeignKey (ﬁeld) loadInfo ( ) query ([sql]) read ([ﬁelds, id]) remove ([id, cascade]) save ([data, validate, ﬁeldList]) saveField ([name, value, validate]) set (one, [two]) setDataSource (dataSource) setSource (tableName) unbindModel (params) validates ([data])</p>
<p>ﬁndAllThreaded([conditions, ﬁelds, sort]) ﬁndCount ([conditions, recursive]) ﬁndNeighbours (conditions, ﬁeld, value)</p>
<p>generateList ([conditions, order, limit, keyPath, val...])</p>
<p>getAffectedRows ( ) getColumnType (column) getColumnTypes ( ) getDisplayField ( ) getID ([list])</p>
<p>cleanUpFields ( ) constructClasses ( ) ﬂash (message, url, [pause]) ﬂashOut (message, url, [pause]) generateFieldNames (data, doCreateO&#8230;) postConditions (data) redirect (url, [status]) referer ([default, local]) render([action, layout, ﬁle]) set (one, [two]) setAction (action, [param, param, param]) validate ( ) validateErrors ( )</p>
<p>element (name) error (code, name, message) pluginView (action, layout) render ([action, layout, ﬁle]) renderCache (ﬁlename, timeStart) renderElement (name, [params]) renderLayout (content_for_layout) setLayout (layout)</p>
<p><strong>Helper</strong></p>
<p>Availability: View only</p>
<p>Callbacks afterDelete ( ) beforeDelete ( ) beforeFind (&amp;qu..) afterFind (results)</p>
<p>beforeSave ( ) beforeValidate ( )</p>
<p>afterSave ( )</p>
<p>Callbacks beforeFilter ( ) afterFilter ( )</p>
<p>beforeRender ( )</p>
<p>Global Constants</p>
<p>Core Deﬁnes</p>
<p>ACL_CLASSNAME ACL_FILENAME AUTO_SESSION CACHE_CHECK CAKE_ADMIN CAKE_SECURITY</p>
<p>CAKE_SESSION_COOKIE</p>
<p>CAKE_SESSION_STRING</p>
<p><strong>Paths</strong></p>
<p>APP APP_DIR APP_PATH CACHE CAKE COMPONENTS CONFIGS CONTROLLER_TESTS CONTROLLERS CSS ELEMENTS HELPER_TESTS HELPERS</p>
<p><strong>Component</strong></p>
<p>INFLECTIONS JS LAYOUTS LIB_TESTS LIBS LOGS MODEL_TESTS MODELS SCRIPTS TESTS TMP VENDORS VIEWS Availability: Controller / View</p>
<p>CAKE_SESSION_TABLE</p>
<p>CAKE_SESSION_TIMEOUT</p>
<p><strong>Properties</strong></p>
<p>$disableStartup</p>
<p>COMPRESS_CSS DEBUG LOG_ERROR MAX_MD5SIZE WEBSERVICES <br />
<strong><br />
Callbacks</strong></p>
<p>startup (&amp;controller)</p>
<p>Properties $tags $base $here $action $themeWeb $view $webroot $params $data $plugin Callbacks</p>
<p>afterRender ( )</p>
<p>CAKE_SESSION_SAVE</p>
<p><strong>Conventions</strong></p>
<p>Class Name: MyCoolComponent</p>
<p>Path: app/controllers/components/my_cool.php</p>
<p><strong>Conventions</strong></p>
<p>Class Name: MyCoolHelper Path: app/views/helpers/my_cool.php</p>
<p>Webroot Conﬁgurable Paths</p>
<p>CORE_PATH ROOT WWW_ROOT WEBROOT_DIR</p>
<p><strong>Usage</strong></p>
<p>Controller: $this-&gt;MyCool-&gt;method( ); View: $this-&gt;controller-&gt;MyCool-&gt;method( );</p>
<p><strong>Usage</strong></p>
<p>View: $myCool-&gt;method( );</p>
<p>CAKE_CORE_INCLUDE_PATH</p>
<p>&nbsp;</p>
<p><a target="_blank" href="http://www.hurricanesoftwares.com/wp-content/uploads/2008/03/cakesheet.pdf">Download CakeSheet Pdf</a> for complete reference.</p>
<p>&nbsp;</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F03%2F03%2Fcakephp-naming-conventions-global-constants-global-functions%2F';
  addthis_title  = 'CakePHP+Naming+Conventions%2C+Global+Constants%2C+Global+Functions';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/03/03/cakephp-naming-conventions-global-constants-global-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP vs Ruby</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/02/22/php-vs-ruby/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/02/22/php-vs-ruby/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 11:50:07 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://hurricanesoftwares.edublogs.org/2008/02/22/php-vs-ruby/</guid>
		<description><![CDATA[PHP vs Ruby &#8211; Practical Language Differences
There are rather significant syntactical differences between PHP and Ruby. For example PHP requires semicolons at the end of lines and generally requires curly brackets to enclose blocks of code. Ruby, on the other hand, uses newline characters to denote the end of a line of code and many [...]]]></description>
			<content:encoded><![CDATA[<h1>PHP vs Ruby &#8211; Practical Language Differences</h1>
<p>There are rather significant syntactical differences between PHP and Ruby. For example PHP requires semicolons at the end of lines and generally requires curly brackets to enclose blocks of code. Ruby, on the other hand, uses newline characters to denote the end of a line of code and many code constructs such as function definitions, and various loops are ended with the word &ldquo;end&rdquo; rather than being surrounded by curly braces. Below is an example of PHP vs Ruby syntax.</p>
<p><strong> PHP Function</strong></p>
<p>function say_hello($name) {<br />
$out = &quot;Hello $name&quot;;<br />
return $out;<br />
}</p>
<p><strong> Ruby Function</strong></p>
<p>def say_hello(name)<br />
out = &quot;Hello ${name}&quot;<br />
return out<br />
end</p>
<p>In Ruby, you don&rsquo;t have to specify the return line as the return value of the last evaluated line is returned automatically. There are other differences in syntax between PHP and Ruby and, in general, Ruby is more concise yet it is not cryptic. Another general note about PHP is that PHP has a very large number of &ldquo;built-in&rdquo; functions &ndash; many more than Ruby. The Rails framework adds some nice helper methods for formatting dates, numbers, currency, and the like. PHP, however, has a vast library of functions that can do almost anything you will need. The naming of the PHP functions and the order of the parameters they take are somewhat inconsistent, but the functions are there making PHP an amazingly complete tool set for web application development. An example of the naming inconsistency is evident in function names such as strpos() vs str_replace(). Sometimes an underscore is used to separate words and other times it&rsquo;s not. While that can be annoying, it&rsquo;s something you can memorize in time and it&rsquo;s not a huge deal. What really matters to me is what can PHP do that Ruby can&rsquo;t and vice versa.</p>
<p>PHP5 was first released over three years ago, July 13, 2007. Frustratingly, and for various compatibility reasons, PHP5 is just now beginning to be an available choice on shared hosting accounts. Nevertheless, my comparison is between PHP5 and Ruby. Both PHP5 and Ruby have object oriented features albeit, Ruby is more sophisticated in terms of OO constructs. But I wanted to know what the real difference is between the languages. When I begin development of my next web application, what will I notice in terms of the differences between the languages.</p>
<p><strong> The Similarities Between PHP and Ruby</strong></p>
<p>Before getting started, I know that PHP and Ruby have very significant syntactic differences and different people may prefer one over the other. So it may be harder to implement certain features in one language over the other. Nevertheless both languages can do almost the same things. Both languages have try/catch/throw style exception handling. Exceptions are new to PHP5 as PHP4 does not have them. Both languages can be used in an object oriented way. Ruby has more powerful object oriented features but most developers probably won&rsquo;t notice a difference in a normal web application. Both languages have additional functionality that can be added through libraries. In general, when developing web applications, I have not yet run into a time when I was working with one language and hit a road block where the language I was using was not capable of expressing the functionality I needed. Sometimes things are easier in one language versus the other but both PHP and Ruby have been able to &ldquo;do&rdquo; the same things.</p>
<p><strong> About Frameworks</strong></p>
<p>You can&rsquo;t talk about Ruby for web development without mentioning Rails. Rails is fantastic and makes developing web applications much easier due to all of the built-in functionality. My favorite aspect of Rails is the ActiveRecord functionality. Often times, many of the objects in my applications are virtually empty except for inheriting from ActiveRecord. Validation is a breeze with Rails and is usually one line such as:</p>
<p>validates_presence_of :attribte_name</p>
<p>The built-in error handling with error_messages_for is very helpful. If you need more flexibility with the display of error messages, there are plugins to available for that. The ability to turn email sending on and off for testing is extremely nice. Having different configuration files for live, testing, and development environments is great.</p>
<p>PHP has over 40 different frameworks available. I&rsquo;ve spent a significant amount of time studying PHP frameworks. The most popular ones appear to by <a href="http://www.cakephp.org" target="_blank">CakePHP</a> and <a href="http://www.symfony-project.org/" target="_blank">Symfony</a>. Both of these frameworks are essentially Rails clones. I think Symfony is the largest, and most comprehensive of the two. My favorite PHP Framework, howevever, is <a href="http://codeigniter.com/" target="_blank">CodeIgniter</a>. It is a Model-View-Controller style framework and has a strong Rails feel to it, but it is much lighter weight. CodeIgniter has no code generators like Rails has. It does have an ActiveRecord style Database class but it is not as powerful as the ActiveRecord in Rails. It is, however, quite nice and very helpful &ndash; much better than nothing. <a href="http://codeigniter.com/" target="_blank">CodeIgniter</a>, as far as I know, does not have anything comparable to Migrations in Rails.</p>
<p><strong> PHP Does Not Have Formal Namespaces</strong></p>
<p>PHP does not officially support namespaces and Ruby does. So organizing your code in a PHP application is something that&rsquo;s left to the developer to figure out. PHP5 has the ability to autoload classess that are undefined. It is a very useful function and one that I have used to organize my code into name spaces. I essentially name classes with underscores separating directory names. Here is my autoload function that replaces underscores with slashes to create a path to the class files that I am using.</p>
<p>define(&quot;PROJECT&quot;, &quot;/path/to/project/classes/&quot;);<br />
define(&quot;LIBRARY&quot;, &quot;/path/to/my/main/php5/library/classes/&quot;);</p>
<p>function __autoload($className) {<br />
$fileName = str_replace(&quot;_&quot;, DIRECTORY_SEPARATOR, $className) . &quot;.php&quot;;<br />
if(preg_match(&quot;/^ProjectName_/&quot;, $className)) {<br />
include_once(PROJECT . $fileName);<br />
}<br />
else {<br />
include_once(LIBRARY . $fileName);<br />
}<br />
}</p>
<p>I have a bunch of classes that I continually reuse in my PHP applications. The path to the root directory of my library is stored in the LIBRARY constant. Any classes I write that either extend my core library or are specific to the project I am working on get stored in the location specified by the PROJECT constant. This has been a system that works really well for me and is a good workaround for PHP not having namespaces. So PHP not having formal namespaces has not really hindered my development efforts.</p>
<p><strong> Documentation</strong></p>
<p>PHP kills Ruby and Rails when it comes to ease of finding, reading, and even generating documentation. The PHP website has wonderful, helpful, searchable documentation. The Rails Documentation is comprehensive but much harder to navigate and has far fewer code examples. PHPDocumentor also produces much better looking documentation that is easier to navigate than RDoc does.</p>
<p><strong> Hosting Ruby (on Rails) Is Painful And Expensive</strong></p>
<p>All the Ruby applications I have developed to date have used the Rails framework. So this is a comparison between hosting a PHP Application and a Ruby on Rails application. PHP has several good MVC style frameworks. My favorite is CodeIgniter and I&rsquo;ll be posting an article about it soon. Using a framework or not, PHP is extremely easy to host. Locate virtually any hosting company, sign up for an account and start dropping your files on the server. I can&rsquo;t say the same for Ruby on Rails.</p>
<p>I started off with a DreamHost account but performance and reliability were miserable. I ended up switching to a virtual dedicated server at Rimu Hosting and have been extremely please with their service. I&rsquo;m running Apache 2.0 + Mongrel + ISPConfig and it&rsquo;s working out nicely. But every time I want to deploy a new application I have to&hellip;</p>
<p>* Set up a mongrel cluster<br />
* Configure 2 or three ports for the mongrel cluster<br />
* Create a map file for my random load balancer<br />
* Set up a way to restart the cluster if the server reboots<br />
* Configure Apache to forward requests to the mongrel cluster<br />
* Configure capistrano to deploy the application.</p>
<p>Fortunately capistrano handles all of the annoying tedium associated with deploying the application and restarting the server. So once capistrano is setup and working, future deployments are a breeze. Also worth noting, this assumes you have your source code in Subversion. So you have to make sure that Subversion is set up and accessible over the internet to the deployment server as well as your development machine. It is good practice to have you source code in version control and you should be doing this whether the project is PHP or Ruby. If you are not using subversion and, therefore, not using capistrano, deploy a rails application is very time consuming and frustrating. Lastly, you need ssh access to your deployment server if you are going to be using <a target="_blank" href="http://www.rubyonrails.org/">Ruby on Rails</a> whereas <a target="_blank" href="http://www.php.net">PHP</a> can be deployed entirely over FTP.</p>
<p>To have a reasonable and reliable hosting environment for Ruby on Rails applications, you should have a virtual private server (VPS) or a dedicated server. So that will cost you at least $50 per month. You can host multiple Rails applications on the same VPS but the RAM requirements for running the mongrel clusters will quickly catch up to you. While you could host well over 50 PHP sites running on your VPS you will only be able to have a handful of Rails applications.</p>
<p><strong> Conclusion</strong></p>
<p>I suspect very few people will argue that PHP is a more elegant language or is more powerful than Ruby. Frankly, Ruby is probably may favorite language that I have ever worked with and I have worked with Classic ASP, ASP.NET, VB.NET, C#, Java, and Perl all rather extensively over the years. Ruby is both highly expressive and concise which is rare and refreshing.</p>
<p>Rails is a very comprehensive and effective web development Framework and there&rsquo;s nothing exactly like it in PHP. You get a huge amount of functionality for free. Developing in Ruby on Rails is also a very fast process because Ruby is a very concise language requiring much less typing than any other language I&rsquo;ve worked with. CodeIgniter is a really nice PHP framework. It will give you a great boost when developing your next PHP application.</p>
<p>The hosting and deployment struggles with Ruby on Rails is a major sticking point for me though. As the owner of a web development company many of our smaller clients do not have the budget for their own VPS account and even if they did, we don&rsquo;t have the staff to manage a large number of VPS accounts or dedicated servers. Keeping the security updates current, managing any issues that may occur with email, and all the other headaches that go along with managing your own VPS or Dedicated server is more than we care to take on for the relatively small, practical dfference between PHP and Ruby. For large projects, it may be worth the trouble, but for small to medium sized projects, PHP is much easier to deploy, less expensive to host, and the language is capable of taking on everything those types of sites require. For our projects, development time with PHP is not noticeably longer than with Ruby on Rails. Ruby on Rails integrates a lot of things for the developer.</p>
<p>There is ActiveRecord for managing the link between models and the database, migrations for keeping development and live databases in sync, built in testing, the ajax &ndash; prototype javascript library is included, and you get a well defined file system structure. While it may not all be packaged together as well, PHP can do all of the above.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F02%2F22%2Fphp-vs-ruby%2F';
  addthis_title  = 'PHP+vs+Ruby';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/02/22/php-vs-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby or PHP which one is for you</title>
		<link>http://hurricanesoftwares.edublogs.org/2008/02/22/ruby-or-php-which-one-is-for-you/</link>
		<comments>http://hurricanesoftwares.edublogs.org/2008/02/22/ruby-or-php-which-one-is-for-you/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 11:27:01 +0000</pubDate>
		<dc:creator>Ashish</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://hurricanesoftwares.edublogs.org/2008/02/22/ruby-or-php-which-one-is-for-you/</guid>
		<description><![CDATA[Will Ruby kill PHP?
With the recent rise in popularity of the Ruby programming language (largely driven by the excellent but not perfect web framework called Rails), I&#8217;ve noticed a little fear in the air &#8230; fear on the part of some people in the PHP community.
Will Ruby kill PHP?
The short answer is: NO.
 MY REASONING
Though [...]]]></description>
			<content:encoded><![CDATA[<h1>Will Ruby kill PHP?</h1>
<p>With the recent rise in popularity of the Ruby programming language (largely driven by the excellent but not perfect web framework called Rails), I&rsquo;ve noticed a little fear in the air &hellip; fear on the part of some people in the PHP community.</p>
<p><strong>Will Ruby kill PHP?</strong></p>
<p>The short answer is: <strong>NO</strong>.</p>
<p><strong> MY REASONING</strong></p>
<p>Though Ruby and PHP are both scripting languages that make developing web applications much easier than it is, say in the Java world, they are very different beasts &hellip; each appeals to a different audience.</p>
<p><strong> RUBY IS ELEGENT BUT COMPLEX</strong></p>
<p>Before I go on, I want to point out that Ruby is a great language and I think it makes perfect sense for PHP developers to learn a little Ruby: it is always a good idea to learn other languages because it will make you a better programmer.</p>
<p>That said, I believe Ruby will not appeal to, or fill the need of most PHP&rsquo;ers &#8211; Ruby can be a little too abstract.</p>
<p><strong> JAVA NERDS LOVE RUBY</strong></p>
<p>Ruby is attracting many from the Java world because it expresses very advanced concepts in a simple syntax &#8211; contrast this to Java&rsquo;s (often times) kludgy and verbose representation.</p>
<p>Ruby appeals to the Java crowd because Java people have been trained to think in terms of large scale enterprise applications &#8211; regardless of the size of the project.</p>
<p>&hellip; These &lsquo;abstractions&rsquo; (generally speaking) lend themselves well to larger projects.</p>
<p><strong> WHY PHP WORKS</strong></p>
<p>PHP is often criticized because it has both a procedural and an object oriented way of doing things. Some people think that this divergence (within the language), takes away from it &hellip; I think this is part of its strength!</p>
<p>Objected oriented constructs are great for creating cleaner designs that are easier to maintain and promote the possibility of code reusability. Code reuseability is an often touted advantage of OOP, but from what I&rsquo;ve seen in the Java world, it is not achieved so often.</p>
<p>With OOP, there is a cost of added complexity and overhead &#8211; you simply have to write more code to do things when you do it via OOP.</p>
<p><strong> PHP PROVES THAT NON OO LANGUAGES STILL HAVE THEIR PLACE</strong></p>
<p>I would suggest that the vast majority of PHP work is found in simple projects:</p>
<p>* Email from a web page.<br />
* Process a simple form and save to a database.<br />
* Create a simple store with 10 items.</p>
<p>My point is, that for many PHP projects, OOP may be a little overkill.</p>
<p><strong> WHY RUBY WILL NOT KILL PHP</strong></p>
<p>In Ruby everything is an object (even numbers!) and the core language has very sophisticated constructs that need to be understood to use Ruby effectively &#8211; Ruby strength is also its&rsquo; weakness.</p>
<p>&hellip; I don&rsquo;t see the majority of PHP users wanting to jump that deep into the world of programmatic abstraction &#8211; for most, there is simply no point.</p>
<p>Ruby is a very clean language and it has lots of things going for it. But PHP has lots of things going for it too. You can point out spots where Ruby code is cleaner than PHP, but you can point out spots where (I think) PHP code is cleaner than Ruby &hellip;</p>
<p>Today I would consider PHP the better choice because it is well established (lots of IDEs, open source projects, easy hosting etc ..) and proven.</p>
<p>Ruby is just starting to get into the mainstream &hellip; and there are still some fundamental issues with Ruby and web development.</p>
<p>For example: Ruby integration with APACHE is still not stable. It works &hellip; but there are known problems and can be a hassle to set up.</p>
<p>Ruby has a long way to go, I can&rsquo;t argue for the programming details as I still like my Perl but from the SysAdmin side Ruby and Rails for the matter are an absolute nightmare.</p>
<p>Ruby in itself is slow, doesn&rsquo;t understand threads like every other language out there so it doesn&rsquo;t integrate into apache like PHP or Perl or Python or the other hundreds of web scripting languages.</p>
<p>Until Mongrel came out you were forced to use fast_cgi, which is a dead method of rendering pages, apache&rsquo;s mod_fcgi is crap and lighttpd&rsquo;s fcgi is better but the server itself is not stable enough for production.</p>
<p>Ruby has to start by modernizing it&rsquo;s preprocessor before it even has a small chance in hell of overtaking PHP and even then Rails has a long way to go before it&rsquo;s ready for the primetime, the ease at which a programmer can cause Rails to leak memory is astounding.</p>
<p>By: Stefan Mischook in <a target="_blank" href="http://www.killerphp.com/articles/evangelizing-php/">Killersite.com</a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fhurricanesoftwares.edublogs.org%2F2008%2F02%2F22%2Fruby-or-php-which-one-is-for-you%2F';
  addthis_title  = 'Ruby+or+PHP+which+one+is+for+you';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://hurricanesoftwares.edublogs.org/2008/02/22/ruby-or-php-which-one-is-for-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
