<?php


class Lib_Code
{

	public function code($table,$id){
		$db = Zend_Registry::get('db');
			
		$select = $db->select();
		$select->from($table);
		$select->where($table.'_id = '.$id);
		$stmt = $db->query($select);
		$data = $stmt->fetchAll(); 

		return $data[0][$table.'_code'];
	}
	
	public function generateCode( $length=10 ) {
		// $consonants = 'abcdefghijklmnouperstwyz';
		// $consonants .= 'ABCDEFGHIJKLMNOUPERSTWYZ';
		// $consonants .= '123456789';
		//	$consonants .= '@#$%';
		
		$consonants = 'ABCDEFGHJKLMNUPRSTWYZ23456789';
		
		$password = '';
		for ($i = 0; $i < $length; $i++) {
			$password .= $consonants[(rand() % strlen($consonants))];
		}
		return $password;
		
	}
}

