johnhamelink
9/4/2012 - 9:06 AM

bbg.php

    protected function setCompanyFinancials($ticker, $row) {
        $company = \Entity\Company::findOneBy(['ticker' => $ticker]);

        if (count($company) > 0) {
            foreach ($this->constHeaders as $header => $label) {
                $financial = new \DataObject('financials');
                $financial->set('key', $header);
                $financial->set('value', $row[$label]);
                $company->getFinancials()->add($financial);
            }

            if($company->save()) {
                return true;
            } else {
                // Company did not save correctly.
                return false;
            }

        } // Ticker not in the DB, return false.

        return false;
    }