if ($table &&
$this->builder->
getTable() !==
$table) { return $this->db->
table($table);
} return $this->builder;
} // We're going to force a primary key to exist
// so we don't have overly convoluted code,
// and future features are likely to require them.
if (empty($this->primaryKey
)) { throw ModelException::
forNoPrimaryKey(static::
class);
} $table =
empty($table) ?
$this->table :
$table;
// Ensure we have a good db connection
if (!
$this->db instanceof BaseConnection
) { $this->db = Database::
connect($this->DBGroup
);
} $builder =
$this->db->
table($table);