public static function _read ($params, &$db = FALSE)
	{
		
		// Create the object

		$obj	= new static;
		
		// If the params are an array
		
		if (is_array ($params))
		{

			// Select all

			$params['select']	= '*';

			// Get data
			
			$row	= static::_getValue ($params, \PDO::FETCH_ASSOC, $db);

			// If no data was returned return FALSE

			if (!$row)
			{
				return FALSE;
			}

			// Set each attribute value

			foreach ($row as $name => $val)
			{

				if ($obj->attributeExists ($name))
				{
					$obj->iset ($name, $val);
				}

			}
			
		}
		
		// Else the params are not an array, so assume pk
		
		else
		{
			
			// Read the object
			
			if (!$obj->read ($params, $db))
			{
				return FALSE;
			}
			
		}
		
		// Return the object
		
		return $obj;
		
	}
public static function _read ($params, &$db = FALSE)
	{
		
		// Create the object

		$obj	= new static;
		
		// If the params are an array
		
		if (is_array ($params))
		{

			// Select all

			$params['select']	= '*';

			// Get data
			
			$row	= static::_getValue ($params, \PDO::FETCH_ASSOC, $db);

			// If no data was returned return FALSE

			if (!$row)
			{
				return FALSE;
			}

			// Set each attribute value

			foreach ($row as $name => $val)
			{

				if ($obj->attributeExists ($name))
				{
					$obj->iset ($name, $val);
				}

			}
			
		}
		
		// Else the params are not an array, so assume pk
		
		else
		{
			
			// Read the object
			
			if (!$obj->read ($params, $db))
			{
				return FALSE;
			}
			
		}
		
		// Return the object
		
		return $obj;
		
	}
public static function _read ( $ params , & $ db = FALSE ) { // Create the object $ obj = new static ; // If the params are an array if ( is_array ( $ params ) ) { // Select all $ params [ 'select' ] = '*' ; // Get data $ row = static :: _getValue ( $ params , \ PDO :: FETCH_ASSOC , $ db ) ; // If no data was returned return FALSE if ( ! $ row ) { return FALSE ; } // Set each attribute value foreach ( $ row as $ name => $ val ) { if ( $ obj -> attributeExists ( $ name ) ) { $ obj -> iset ( $ name , $ val ) ; } } } // Else the params are not an array, so assume pk else { // Read the object if ( ! $ obj -> read ( $ params , $ db ) ) { return FALSE ; } } // Return the object return $ obj ; }
Create a new object instance and read it from the database, populating the object attributes
@param mixed $params Object to read.
This can be an instance ID or a parameter array.
@param \PDO $db Database connection to use
@return \Sonic\Model
Create a new object instance and read it from the database populating the object attributes