protected function builder(string $table = null)
	{
		if ($this->builder instanceof BaseBuilder)
		{
			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(get_class($this));
		}

		$table = empty($table) ? $this->table : $table;

		// Ensure we have a good db connection
		if (! $this->db instanceof BaseConnection)
		{
			$this->db = Database::connect($this->DBGroup);
		}

		$this->builder = $this->db->table($table);

		return $this->builder;
	}
protected function builder(string $table = null)
	{
		if ($this->builder instanceof BaseBuilder)
		{
			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(get_class($this));
		}

		$table = empty($table) ? $this->table : $table;

		// Ensure we have a good db connection
		if (! $this->db instanceof BaseConnection)
		{
			$this->db = Database::connect($this->DBGroup);
		}

		$this->builder = $this->db->table($table);

		return $this->builder;
	}
protected function builder ( string $ table = null ) { if ( $ this -> builder instanceof BaseBuilder ) { 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 ( get_class ( $ this ) ) ; } $ table = empty ( $ table ) ? $ this -> table : $ table ; // Ensure we have a good db connection if ( ! $ this -> db instanceof BaseConnection ) { $ this -> db = Database :: connect ( $ this -> DBGroup ) ; } $ this -> builder = $ this -> db -> table ( $ table ) ; return $ this -> builder ; }
Provides a shared instance of the Query Builder.

@param string $table

@return BaseBuilder
Provides a shared instance of the Query Builder .