Udi Mosayev

Programming, Business and my thoughts..

Packt Publishing Offers New Discounts on Multiple Purchases

Packt, publisher of specialist IT books, has today announced the launch of new discounts for any orders of multiple books.
Visitors to www.packtpub.com who purchase 2-4 books will automatically receive an 18% discount, while those who purchase 5-10 books will receive 20% off of the books’ cover prices.
These discounts are available across all of Packt’s hard copy books bought via the company’s website, and organisations of all sizes are offered the opportunity to obtain books for their employees or members at discounted prices.
Larger discounts are on offer as well. If a greater number of books are required, an email address has been set up – BulkSales@PacktPub.com – to help customers contact us about ordering in bulk much more efficiently. “Particularly since the launch of Packt Enterprise and Packt Open Source, Packt’s books are becoming ever more focussed, and therefore increasingly relevant to the specific needs of larger organisations.”, said Mark Nichols, marketing executive at Packt Publishing. “These new, easy to access discounts means that facilitating purchases in bulk will be much more simple.”

Enjoy =]


View Comments

Written by Udi Mosayev

July 20th, 2010 at 9:02 pm

Posted in General Talk

New PHP Book: Expert PHP 5 Tools by Dirk Merkel

Recently I came across Expert PHP 5 Tools from Packt Publishing, and I’m getting the review copy very soon.

By the information written in Packt’s book page, I see that the book is about all the surrounding of PHP. The IDE, the server, documenting tools and etc.

I haven’t read the book yet, but I don’t think you really need to be an expert to use the tools, its more then enough to have some experience, at least write few web applications with PHP.

I can’t wait to read the book, I really want to read about “Deploying Applications” and “Continuous Integration”, of course I’ll review the book for you.

You can find more information here: Expert PHP 5 Tools and the Table of Contents here.


View Comments

Written by Udi Mosayev

June 27th, 2010 at 5:49 pm

Posted in General Talk,PHP,Web Development

Tagged with ,

Book Review: “CodeIgniter 1.7 Professional Development” by Adam Griffiths

The book “CodeIgniter 1.7 Professional Development” written by Adam Griffiths. I’ve already wrote a little bit about the book before, and Few days ago I got it in the mail and finished reading it already.

The author is a well known developer in the CodeIgniter community, who also contributed nice authentication library. So as expected, I saw a lot of high quality information in the book, and the experience of the author with CodeIgniter is shown. If I only read the book a year ago, I could’ve become better CodeIgniter developer much faster.

Though the first chapter dedicated to get you started with CodeIgniter, I think its the best if you already have some experience with the framework. And even long-time CodeIgniter developers might find valuable information.

Personally I enjoyed reading about building large scale application [Chapter 7] and the timing is perfect because of the project I’m working on. In my opinion, before reading this book, you must have some experience with CodeIgniter [build 1 applicaiton in CI and you're good to go in my opinion], and this book really can turn you into professional. Use the knowledge you get from this book  and you’ll be much better CodeIgniter developer.

Another chapter I liked is Chapter 10 – Developing and Releasing Code to the Community. Although its quite short chapter, there is a lot of information regarding this subject. The author shared in the chapter his experience writing and maintaining the Authentication library and I really enjoyed it. It motivates you to create and share :) .

What I was missing in the book, and I think most of the beginners would find it useful is Application Structure examples. Discussing different ways you can build real life web applications that almost every developers writes at some point.

CodeIgniter is amazing PHP framework, its lightweight, very flexible and simple to understand. “CodeIgniter 1.7 Professional Development” contains very valuable information and practices, that can turn any newbie into skilled CodeIgniter developer. As I already said, if I only had this book a year ago, I could have become better CodeIgniter developer much faster.

For more information about the book & purchase, visit book’s page at PacktPub.com.


View Comments

Written by Udi Mosayev

June 4th, 2010 at 11:19 pm

My experience with CloudIgniter

Recently I got an opportunity to use CloudIgniter – Codeigniter Hosting, with your own database and ftp account.
In my account I can have 3 domains, I’ve added the first one: helloworld.co.il and I have few options:

  • Platform – CodeIgniter 1.7.2, CodeIgniter 2.0 beta
  • Application – Different versions of PyroCMS and MyClientBase.

I chose PyroCMS.

What it does, is installing the application on your account, in your Database, and login info to Pyro are automatically the login info to your CloudIgniter account and you can start working.

I’m located in Israel, and I have my experience with hosting servers outside Israel and most of them [Dreamhost for example] are nightmare for me, the FTP connection specially. But CloudIgniter servers are quite good, not as fast as Israeli servers I’m working on but their good [considering the distance].

The CloudIgniter admin panel is very simple to understand and navigate, you can find very simple Domain Management [with all the info you need], Usage information, setup Google Apps account for emails, and account settings.

To sum it up:

  • You have FTP account, Database, phpMyAdmin – everything you need.
  • Can manage more then 1 domain, I believe it will be part of their business plan. Each domain can be different CI installation/application.
  • There’s a backup plan, I don’t know which – but if you change the CI installation for certain domain it backups the old one.
  • Usage information – not full detailed, but good enough.
  • Clean and simple Admin Panel design.

CloudIgniter is at beta phase, you can go to CloudIgniter and ask for beta slot.

Good luck!


View Comments

Written by Udi Mosayev

May 29th, 2010 at 2:38 pm

Tuesday / May 18th

twitter (feed #4)
Wow.. My RSS feed subscribers almost doubled today.. thanks guys :D [udiudi]
generic (feed #5)
generic (feed #5)
generic (feed #5)
twitter (feed #4)
RT @philsturgeon: ~21 year old blonde girls get a 50% discount to @cicon2010. Send photos this way for assessment before getting your di … [udiudi]
twitter (feed #4)
Cool Photos!! RT @palmedic Infected mushroom, last night’s live performance photos http://bit.ly/cGMBVX [udiudi]
twitter (feed #4)
Integrated JIRA with Eclipse :D more convenient. ditched Aptana, and tweaked eclipse.ini for better performance. [udiudi]
generic (feed #5)
twitter (feed #4)
seriously considering changing my modular separation method to this: http://bit.ly/9fM2JB much more powerful. any thoughts about that? [udiudi]
twitter (feed #4)
Finally ordered some tea from @samovarlife :) [udiudi]
digg (feed #3)
generic (feed #5)
generic (feed #5)
generic (feed #5)
generic (feed #5)

View Comments

Written by Udi Mosayev

May 18th, 2010 at 11:02 pm

Posted in General Talk

Monday / May 17th

blog (feed #1)

Hi,
I wanted to share with you MY_Model I’ve written and use for most of my CodeIgniter apps.

/**
* This is the basic mod…

twitter (feed #4)
digg (feed #3)
digg (feed #3)
digg (feed #3)
digg (feed #3)
digg (feed #3)

View Comments

Written by Udi Mosayev

May 17th, 2010 at 8:00 pm

Posted in General Talk

MY_Model in CodeIgniter

Hi,

I wanted to share with you MY_Model I’ve written and use for most of my CodeIgniter apps.

/**
 * This is the basic model class.
 *
 * @package - Infrastructure
 * @category - Model
 * @author - Udi Mosayev @ umNet
 * @link - udi.mosayev@gmail.com
 * @since - Version 1.0
 */
class MY_Model extends CI_Model {

	// The main table name
	public $table;

	private $modelName;

	public function MY_Model() {
		parent::CI_Model();
		$this->table = '';
		$this->modelName = __CLASS__;
	}

	// Log as Error each time nonexisting method called.
	public function __call($name, $arguments) {
		$args = implode(',',$arguments);
		$this->log('error', $name.'('.$args.') Not exists');
		return FALSE;
	}

	/**
	 * Logs an error
	 * @param String $level
	 * @param String $msg
	 */
	protected function log($level, $msg) {
		log_message($level, __CLASS__.'->'.__METHOD__.' :: '.$msg.' | In: '.__FILE__.' Line: '.__LINE__);
	}
	/**
	 * This method inserts some array of data into the db
	 * @param Array $data
	 */
	public function save($data) {
		if(is_array($data)) {
			$this->db->insert($this->table, $data);
			return $this->db->insert_id();
		} else {
			$this->log('error', 'got non-array param.');
			return FALSE;
		}
	}

	/**
	 * This method updates fields in my table.
	 * @param String $fieldName
	 * @param String $value
	 * @param Integer $RowID
	 */
	public function updateField($fieldName, $fieldValue, $rowID) {
		if(empty($fieldName)) {
			$this->log('error', 'got empty fieldName');
			return FALSE;
		}
		else if(empty($fieldValue)) {
			$this->log('error','got empty fieldValue');
			return FALSE;
		}
		else if(!is_numeric($rowID)) {
			$this->log('error', 'got non-numeric RowID: '.$rowID);
			return FALSE;
		} else {
			// Wrtite the old&new data to history.
			$this->history->write($this->table, $rowID, $fieldName, $fieldValue);

			$this->db->where('ID', $rowID);
			$this->db->update($this->table, array($fieldName => $fieldValue));

			return TRUE;
		}
	}

	/**
	 * Updates whole row [unlike updateFIeld()]
	 * @param Array $RowData
	 * @param Integer $RowID
	 */
	public function update($RowData, $RowID) {

		if(!is_array($RowData)) {
			$this->log('error', 'supposed to get an array!');
			return FALSE;
		} else if(!is_numeric($RowID)) {
			$this->log('error', 'got non-numeric RowID: '.$RowID);
			return FALSE;
		} else {
			// write the old&new data to history
			foreach($RowData as $fieldName=>$fieldValue) {
				log_message('debug', 'Running history->write() with: history->write('.$this->table.', '.$RowID.', '.$fieldName.', '.$fieldValue.')');
				$this->history->write($this->table, $RowID, $fieldName, $fieldValue);
			}

			$this->db->where('ID', $RowID);
			$this->db->update($this->table, $RowData);
		}
	}

	/**
	 * This method returns all the rows of this model
	 * @param Array $where
	 */
	public function getWhere($where = "") {
		// if not array, then assign defaultive array for where clause
		if(!is_array($where)) $where = array('IsDeleted' => 0);
		$query = $this->db->get_where($this->table, $where);

		return $query;
	}

	/**
	 * This method gets 1 row from a table and returns it.
	 * @param Integer $RowID
	 */
	public function get($RowID) {
		if(!is_numeric($RowID)) {
			$this->log('error', 'Did NOT got a numeric RowID.');
			return FALSE;
		} else {
			$query = $this->db->get_where($this->table, array('ID' => $RowID));
			return $query;
		}
	}

	public function delete($RowID) {
		if(is_numeric($RowID)) {
			$this->updateField('IsDeleted', 1, $RowID);
			return TRUE;
		} else {
			return FALSE;
		}
	}
}

/* End of file MY_Model.php*/
/* Location: ./application/model/MY_Model.php */

I need to explain few things:

  • I use logical delete, I have field called IsDeleted its TINYINT, and if I want to delete certain row I update its value to 1. This method has lots of benefits which I can’t discuss now.
  • I use two “read” methods, get() and getWhere(), I KNOW that get() should use getWhere inside, but I don’t really have the time for this little fix :P
  • This class rewritten for CodeIgniter 2.0, so that’s why I extend CI_Model, if you’re using CodeIgniter 1.7 just write Model instead.
  • In each app I add more methods, methods that I need in all my models, or at least in some of them. For example a method that re-orders the item in the table.

Ask any thing you want, I’ll be happy to help.

UPDATE:

In line 98 you see this:

$this->history->write($this->table, $RowID, $fieldName, $fieldValue);

if you remember, I wrote about System Restore feature in Must Have Features in you CMS, this is my implementation for this feature. Thank you Zack for noticing!


View Comments

Written by Udi Mosayev

May 17th, 2010 at 5:55 pm

Sunday / May 16th

generic (feed #5)
Posted Vimeo.
twitter (feed #4)
RT @justinvincent: Why Mark Zuckerberg Needs to Come Clean About his Views on Privacy http://bit.ly/ah9qA5 [udiudi]
twitter (feed #4)
RT @tferriss: How to get your dream job for $6 using Google Adwords: http://ping.fm/dvgrw Awesome. (via @titanas) [udiudi]
generic (feed #5)
twitter (feed #4)
Creating features I don’t believe in.. THAT’S SUCKS! #hardstartuplife [udiudi]

View Comments

Written by Udi Mosayev

May 16th, 2010 at 8:22 pm

Posted in General Talk

Saturday / May 15th

generic (feed #5)
generic (feed #5)
twitter (feed #4)
Uploading 819 files to @Dropbox – "a long time left. Grab a Snickers." [udiudi]
generic (feed #5)
blog (feed #1)

Hi,
Yesterday I wrote about the new CodeIgniter book: CodeIgniter 1.7 Professional Development By Adam Griffiths.
Packt Publi…

twitter (feed #4)
looking for working addons/extensions to block facebook’s like buttons. [udiudi]

View Comments

Written by Udi Mosayev

May 15th, 2010 at 8:10 pm

Posted in General Talk

Database Interaction with Codeigniter 1.7

Hi,

Yesterday I wrote about the new CodeIgniter book: CodeIgniter 1.7 Professional Development By Adam Griffiths.
Packt Publishing extracted an article from the book, “Database Interaction with Codeigniter 1.7” which can be very helpful for beginners. You’ll read about the Database class, ActiveRecord and Database Forge class that gives you few methods to perform different [not so casual] operations in your database.

I really recommend you to not use ActiveRecord if you’re not familiar with SQL. If you’ll use ActiveRecord from day 1, you wouldn’t really know whats happening under the hood. My opinion is the same about PHP frameworks, I don’t think its good idea to start working with a framework before you know the language good enough.
Although not using ActiveRecord you won’t enjoy the security of injections-free queries and multiple DB types support – but in the long run its better for you as web developer.

Moreover, consider extending the native Model and writing simple CRUD [Create/Read/Update/Delete] methods that can help you working faster and better. I promise I’ll write about it more, I wrote for my self a quite powerful MY_Model class.

This is it for now,
If you already got the book, share your thoughts with me.


View Comments

Written by Udi Mosayev

May 15th, 2010 at 7:17 pm