public function insertObject($table, &$object, $key = null)
	{
		// Initialise some variables
		$fields = [];
		$values = [];
		$binds  = [];

		// Create the base insert statement
		$statement = 'INSERT INTO ' . $this->quoteName($table) . ' (%s) VALUES (%s)';

		// Iterate over the object variables to build the query fields and values
		foreach (get_object_vars($object) as $k => $v)
		{
			// Only process non-null scalars
			if (is_array($v) or is_object($v) or $v === null)
			{
				continue;
			}

			// Ignore any internal fields
			if ($k[0] == '_')
			{
				continue;
			}

			// Prepare and sanitize the fields and values for the database query
			$fields[] = $this->quoteName($k);
			$values[] = '?';
			$binds[]  = $v;
		}

		// Set the query and execute the insert
		$this->prepare(sprintf($statement, implode(',', $fields), implode(',', $values)))
		     ->bind($binds);

		if (!$this->execute())
		{
			return false;
		}

		// Update the primary key if it exists
		$id = $this->insertid();
		if ($key && $id)
		{
			$object->$key = $id;
		}

		return true;
	}