system/Database/Postgre/Builder.php
public function replace(array $set = null, bool $returnSQL = false)
	{
		if ($set !== null)
		{
			$this->set($set);
		}

		if (! $this->QBSet)
		{
			if (CI_DEBUG)
			{
				throw new DatabaseException('You must use the "set" method to update an entry.');
			}
			return false;
		}

		$table = $this->QBFrom[0];

		$set = $this->binds;

		// We need to grab out the actual values from
		// the way binds are stored with escape flag.
		array_walk($set, function (&$item) {
			$item = $item[0];
		});

		$keys   = array_keys($set);
		$values = array_values($set);

		$builder = $this->db->table($table);
		$exists  = $builder->where("$keys[0] = $values[0]", null, false)->get()->getFirstRow();

		if (empty($exists))
		{
			$result = $builder->insert($set);
		}
		else
		{
			array_pop($set);
			$result = $builder->update($set, "$keys[0] = $values[0]");
		}

		unset($builder);
		$this->resetWrite();

		return $result;
	}
public function replace(array $set = null, bool $returnSQL = false)
	{
		if ($set !== null)
		{
			$this->set($set);
		}

		if (! $this->QBSet)
		{
			if (CI_DEBUG)
			{
				throw new DatabaseException('You must use the "set" method to update an entry.');
			}
			return false;
		}

		$table = $this->QBFrom[0];

		$set = $this->binds;

		// We need to grab out the actual values from
		// the way binds are stored with escape flag.
		array_walk($set, function (&$item) {
			$item = $item[0];
		});

		$keys   = array_keys($set);
		$values = array_values($set);

		$builder = $this->db->table($table);
		$exists  = $builder->where("$keys[0] = $values[0]", null, false)->get()->getFirstRow();

		if (empty($exists))
		{
			$result = $builder->insert($set);
		}
		else
		{
			array_pop($set);
			$result = $builder->update($set, "$keys[0] = $values[0]");
		}

		unset($builder);
		$this->resetWrite();

		return $result;
	}
Replace

Compiles an replace into string and runs the query.
Because PostgreSQL doesn't support the replace into command,
we simply do a DELETE and an INSERT on the first key/value
combo, assuming that it's either the primary key or a unique key.

@param array   $set       An associative array of insert values
@param boolean $returnSQL

@return   mixed
@throws   DatabaseException
@internal param true $bool returns the generated SQL, false executes the query.