public function save($data): bool
	{
		if (empty($data))
		{
			return true;
		}

		if (is_object($data) && isset($data->{$this->primaryKey}))
		{
			$response = $this->update($data->{$this->primaryKey}, $data);
		}
		elseif (is_array($data) && ! empty($data[$this->primaryKey]))
		{
			$response = $this->update($data[$this->primaryKey], $data);
		}
		else
		{
			$response = $this->insert($data, false);
			// call insert directly if you want the ID or the record object
			if ($response !== false)
			{
				$response = true;
			}
		}

		return $response;
	}
public function save($data): bool
	{
		if (empty($data))
		{
			return true;
		}

		if (is_object($data) && isset($data->{$this->primaryKey}))
		{
			$response = $this->update($data->{$this->primaryKey}, $data);
		}
		elseif (is_array($data) && ! empty($data[$this->primaryKey]))
		{
			$response = $this->update($data[$this->primaryKey], $data);
		}
		else
		{
			$response = $this->insert($data, false);
			// call insert directly if you want the ID or the record object
			if ($response !== false)
			{
				$response = true;
			}
		}

		return $response;
	}
public function save ( $ data ) : bool { if ( empty ( $ data ) ) { return true ; } if ( is_object ( $ data ) && isset ( $ data -> { $ this -> primaryKey } ) ) { $ response = $ this -> update ( $ data -> { $ this -> primaryKey } , $ data ) ; } elseif ( is_array ( $ data ) && ! empty ( $ data [ $ this -> primaryKey ] ) ) { $ response = $ this -> update ( $ data [ $ this -> primaryKey ] , $ data ) ; } else { $ response = $ this -> insert ( $ data , false ) ; // call insert directly if you want the ID or the record object if ( $ response !== false ) { $ response = true ; } } return $ response ; }
A convenience method that will attempt to determine whether the
data should be inserted or updated. Will work with either
an array or object. When using with custom class objects,
you must ensure that the class will provide access to the class
variables, even if through a magic method.

@param array|object $data

@return boolean
@throws \ReflectionException
A convenience method that will attempt to determine whether the data should be inserted or updated . Will work with either an array or object . When using with custom class objects you must ensure that the class will provide access to the class variables even if through a magic method .