Friday, February 11, 2011

About ExpressionEngine [EE]

Expression Engine is a very powerful content management system that can be used to manage your website and blog. All you have to do is add EE tags into the portions of your pages where you want your posts / content to appear. It has all the inbuilt basic features that is required to create a website. However, for more complex implementation you would need to buy / get free add-ons or hack the code to suit your needs.

Fetching and displaying the data is an easy part. Challenge comes in when you want to display it in a more creative way.

Like at one such instance, we needed a feature to add ratings for an article and at the same time add customer's review. To achieve this we simply made changes to the add-on's class file, added a field to the ratings table in the database to store the reviews as well as the score, since we wanted to display the customers review for the article along with the rating.

Second, displaying breadcrumbs in a customized way. Though there are add-ons available for the same, but add-on's displayed the breadcrumbs based on the query string. So, we had to modify the class file to suit our requirements.

Third, in certain cases there were limitations to using EE tags, particularly nested "weblog" tags. To overcome such situations we have used queries instead to fetch the required data for further processing in the inner loops.


Conclusion

So, unlike learning any new application especially content management systems, learning EE was comparatively less painful. The more you work on it, the more you discover about its potential. Be it a usual CMS site, Shopping Carts, Blogs etc. EE

How to get next auto increment value of a primary key field in MySql?

<?php
function mysql_next_id($table) {
$result = mysql_query('SHOW TABLE STATUS LIKE "'.$table.'"');
$rows = mysql_fetch_assoc($result);
return $rows['auto_increment'];
}
?>

Programmers try other ways to retrieve the next auto-generated id and fail to get correct value.

Example:
Most of the programmers try to get the MAX(id)+1 (or sort the table in decending order and get the first id) but this will not to work when you delete the last record.

There is a possibility that other users have entered record in the meantime, in this case the value that you have retrieved would be incorrect. You may use LOCK TABLES to prevent such a case.

However, the best thing is to avoid such logics.