Monthly Archives: August 2012

joomla store value Using the JTable Class

The first step is to extend the JTable class with your new table class in table folder:

class TableRestaurant extends JTable 
   var $id = null; 
   var $name = null; 
   var $address = null; 
   var $comments = null; 
   var $comment_date = null;
   var $published = null; 
   function __construct(&$db) 
      parent::__construct( '#__restaurant', 'id', $db );

To include the file, place this line in your extension's source code (use com_nameofyourcomponent in place of com_restaurant):
To get an instance of the object, use this code:
$row =& JTable::getInstance('restaurant', 'Table');

In a model class (extends JModel) you can also use:

$row =& $this->getTable('restaurant');

Updating is as simple as setting the row values in this manner.

$row->name = 'ashwin';
$row->address = 'test address';
$row->comments = 'Open Source Developer';
// Save results

Notice that the $row object of type TableRestaurant has all the columns we defined above.  When we call the store() method these rows are automatically stored in the database.  Our code above assumes that the id field will be auto-incremented on store(), so we are not providing a value for this field (as well as comment_date and published).  So this code will store a new value for this restaurant (essentially running and 'INSERT' query for us).  If we had provided value for the id field, the store() method would have instead 'UPDATE' query.

random coupon generator in php

	$passes = array();
 	$chars = "abcdefghkmnopqrstuvwxyz023456789";
	$amount = 100;
	$lenght = 6;   

	for($j=0; $j<$amount; $j++)

		 $i = 0; $pass = '' ;
		 while ($i <= $length)
		 { $num = rand() % 33; $tmp = substr($chars, $num, 1);
		 $pass = $pass . $tmp; $i++;
		 $passes[] = $pass;

	foreach($passes as $password)
		echo strtoupper(substr(md5($password),0,15))."<br />";