New update and phone update!

Hello people,

Sorry I haven’t written in a fair while, been pretty busy with Uni and Work.

Quick update:

  • Well I’m back at Uni and enjoying it so far, sorted out my placement for next year at PC Call Ltd (www.pchome-call.com) very cool company to be working with.
  • Got rid of my Nokia N97, got fed up with the consistent crashed and problems and I have now joined the rest of the world and got an iPhone (3GS 32GB) very cool phone and loving it so far!
  • Upgraded to Windows 7 64 bit, so far so good, watch out for a blog article coming soon about it.

That’s about all for now, please comment if you wish to make any remarks!

Dan

Tagged with:
 

First go at using CodeIgniter

Well, after lots of playing around with my Multi-User database systems assignment in PHP, I have decided to try and have a go with CodeIgniter, a popular open source PHP framework.

The concept is very simple, a prewritten set of classes are available for you to use to make writing in PHP easier and quicker (supposedly!) it takes a bit of getting used to but once getting the hang of it, its a very powerful tool and there is a lot of help out there, for example today, I was trying to look up a value in a table when submitting a form, making sure that it doesn’t already exist and if it does, throw up an error message to the user, if its not there, continue the code. I natually had a Google and found the following prewritten class that I can just pop into the my CodeIgniter libraries folder and it’s readily available to user, find the code below (with thanks to: ScottNelle.com):

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * MY_Form_validation Class
 *
 * Extends Form_Validation library
 *
 * Adds one validation rule, "unique" and accepts a
 * parameter, the name of the table and column that
 * you are checking, specified in the forum table.column
 *
 * Note that this update should be used with the
 * form_validation library introduced in CI 1.7.0
 */
class MY_Form_validation extends CI_Form_validation {
 
	function My_Form_validation()
	{
	    parent::CI_Form_validation();
	}
 
	// --------------------------------------------------------------------
 
	/**
	 * Unique
	 *
	 * @access	public
	 * @param	string
	 * @param	field
	 * @return	bool
	 */
	function unique($str, $field)
	{
		$CI =& get_instance();
		list($table, $column) = split("\.", $field, 2);
 
		$CI->form_validation->set_message('unique', 'The %s that you requested is unavailable.');
 
		$query = $CI->db->query("SELECT COUNT(*) dupe FROM $table WHERE $column = '$str'");
		$row = $query->row();
		return ($row->dupe > 0) ? FALSE : TRUE;
	}
}
?>

This is then uploaded to the /libraries folder in your system and then in the controller you simply use when needed, find a snippet of my registration.php code below:

$this->form_validation->set_rules('CustomerID', 'Username', 'required|min_length[8]|max_length[20]|unique[Customers.CustomerID]');
//Pay special attention to Customers.CustomerID this is basically TABLE.COLUMN that you wish to check
		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('registration', $headerdata);
		}
		else
		{
			//Add data to the table
                 }

There we go, my first go at CodeIgniter. I’m sure I’ll be posting more snippets shortly, With thanks to Ben Harris for suggesting CodeIgniter to me and giving me a fair amount of help with the code today.

Have fun!

Tagged with:
 
Page 1 of 212»

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

© 2010 Daniel Smith