<?php
namespace GoRemote\Model;

class CompanyModel
{
	public $id = 0;
	public $name;
	public $url = '';
	public $twitter;
	public $logo;

	public function insert(\Doctrine\DBAL\Connection $db)
	{
		$duplicateId = $db->fetchAssoc(
			'select companyid, url, logo from companies where name=?',
			[
				(string) $this->name
			]);

		if ($duplicateId) {
            if (empty($duplicateId['logo']) && !empty($this->logo)) {
                $db->createQueryBuilder()
                    ->update('companies')
                    ->set('logo', '?')
                    ->where('companyid = ?')
                    ->setParameter(0, $this->logo)
                    ->setParameter(1, $duplicateId['companyid']);
            }
			$this->id = $duplicateId;
			return $duplicateId;
		}

		$company = [
			'name' => $this->name,
			'dateadded' => date('Y-m-d H:i:s'),
			'logo' => $this->logo,
			'twitter' => $this->twitter,
			'url' => $this->url
		];

		$db->insert('companies', $company);
		$this->id = $db->lastInsertId();
		return $this->id;
	}
}
<?php
namespace GoRemote\Model;

class CompanyModel
{
	public $id = 0;
	public $name;
	public $url = '';
	public $twitter;
	public $logo;

	public function insert(\Doctrine\DBAL\Connection $db)
	{
		$duplicateId = $db->fetchColumn(
			'select companyid from companies where name=?',
			[
				(string) $this->name
			]);

		if ($duplicateId) {
			$this->id = $duplicateId;
			return $duplicateId;
		}

		$company = [
			'name' => $this->name,
			'dateadded' => date('Y-m-d H:i:s'),
			'logo' => $this->logo,
			'twitter' => $this->twitter,
			'url' => $this->url
		];

		$db->insert('companies', $company);
		$this->id = $db->lastInsertId();
		return $this->id;
	}
}
--- 
+++ 
@@ -11,13 +11,21 @@
 
 	public function insert(\Doctrine\DBAL\Connection $db)
 	{
-		$duplicateId = $db->fetchColumn(
-			'select companyid from companies where name=?',
+		$duplicateId = $db->fetchAssoc(
+			'select companyid, url, logo from companies where name=?',
 			[
 				(string) $this->name
 			]);
 
 		if ($duplicateId) {
+            if (empty($duplicateId['logo']) && !empty($this->logo)) {
+                $db->createQueryBuilder()
+                    ->update('companies')
+                    ->set('logo', '?')
+                    ->where('companyid = ?')
+                    ->setParameter(0, $this->logo)
+                    ->setParameter(1, $duplicateId['companyid']);
+            }
 			$this->id = $duplicateId;
 			return $duplicateId;
 		}
Update company logos if they didn't previously have one but they do now
