<?php
class Domain extends MY_Model
{
	const DB_TABLE = 'domains';
    const DB_TABLE_PK = 'domain_id';

    function LoadByDomain($domain)
	{
	  	$query = $this->db->query("SELECT *
	  								FROM domains
	  								WHERE ? LIKE CONCAT('%', domain, '%')
	  								ORDER BY LENGTH(domain) DESC",
	  								array($domain));
		// ORDER BY LENGTH required in order to override landing pages in the event of "domain.com/location" sites.

	  	if($query->num_rows() > 0)
	  	{
	  		foreach($query->result() as $row)
	  		{
	  			//load the first item
				return $this->populate($row);
	  		}
	  	}
	  	else
	  	{
	  		return false;
	  	}
	}


}
