public function create ($exclude = array (), &$db = FALSE)
	{
		
		// Get columns and values
		
		$create	= $this->createColumnsAndValues ($exclude);
		
		// Get database master for write
		
		if ($db === FALSE)
		{
			$db	=& $this->getDbMaster ();
		}
		
		// Prepare query
		
		$query	= $db->prepare ('
		INSERT INTO `' . static::$dbTable . '` (' . $create['columns'] . ')
		VALUES ( ' . $create['values'] . ')
		');
		
		// Bind attributes
		
		$this->bindAttributes ($query, $exclude);
		
		// Execute
		
		if (!$this->executeCreateUpdateQuery ($query))
		{
			return FALSE;
		}
		
		// Set the pk

		if (!$this->attributeHasValue (static::$pk) || !$this->iget (static::$pk))
		{
			$this->iset (static::$pk, $db->lastInsertID ());
		}
		
		// Changelog
		
		if ($this->changelog ('create'))
		{
			$log =& $this->getResource ('changelog');
			$log->hookTransactions ($db);
			$log::_Log ('create', static::_Read ($this->iget (static::$pk), $db));
		}

		// return TRUE

		return TRUE;
		
	}
public function create ($exclude = array (), &$db = FALSE)
	{
		
		// Get columns and values
		
		$create	= $this->createColumnsAndValues ($exclude);
		
		// Get database master for write
		
		if ($db === FALSE)
		{
			$db	=& $this->getDbMaster ();
		}
		
		// Prepare query
		
		$query	= $db->prepare ('
		INSERT INTO `' . static::$dbTable . '` (' . $create['columns'] . ')
		VALUES ( ' . $create['values'] . ')
		');
		
		// Bind attributes
		
		$this->bindAttributes ($query, $exclude);
		
		// Execute
		
		if (!$this->executeCreateUpdateQuery ($query))
		{
			return FALSE;
		}
		
		// Set the pk

		if (!$this->attributeHasValue (static::$pk) || !$this->iget (static::$pk))
		{
			$this->iset (static::$pk, $db->lastInsertID ());
		}
		
		// Changelog
		
		if ($this->changelog ('create'))
		{
			$log =& $this->getResource ('changelog');
			$log->hookTransactions ($db);
			$log::_Log ('create', static::_Read ($this->iget (static::$pk), $db));
		}

		// return TRUE

		return TRUE;
		
	}
public function create ( $ exclude = array ( ) , & $ db = FALSE ) { // Get columns and values $ create = $ this -> createColumnsAndValues ( $ exclude ) ; // Get database master for write if ( $ db === FALSE ) { $ db = & $ this -> getDbMaster ( ) ; } // Prepare query $ query = $ db -> prepare ( '
		INSERT INTO `' . static :: $ dbTable . '` (' . $ create [ 'columns' ] . ')
		VALUES ( ' . $ create [ 'values' ] . ')
		' ) ; // Bind attributes $ this -> bindAttributes ( $ query , $ exclude ) ; // Execute if ( ! $ this -> executeCreateUpdateQuery ( $ query ) ) { return FALSE ; } // Set the pk if ( ! $ this -> attributeHasValue ( static :: $ pk ) || ! $ this -> iget ( static :: $ pk ) ) { $ this -> iset ( static :: $ pk , $ db -> lastInsertID ( ) ) ; } // Changelog if ( $ this -> changelog ( 'create' ) ) { $ log = & $ this -> getResource ( 'changelog' ) ; $ log -> hookTransactions ( $ db ) ; $ log :: _Log ( 'create' , static :: _Read ( $ this -> iget ( static :: $ pk ) , $ db ) ) ; } // return TRUE return TRUE ; }
Create object in the database
@param array $exclude Attributes not to set
@param \PDO $db Database connection to use, default to master resource
@return boolean
Create object in the database