select() ->where("idClient='".$param->idClient."' AND name='".$param->dirNom."' AND nameType='".$param->dirType."' AND LEFT(nameIdentifier, 3)='so_'") ->order('dateInsert DESC'); if ($this->fetchRow($sql)) { $result->nameIdentifier = $this->fetchRow($sql)->nameIdentifier; $result->matchCount = $this->fetchRow($sql)->matchCount; } else { $wc = new WsWorldCheck(); $data = new stdClass(); $data->name = $param->dirNom; $data->nameType = $param->dirType; $result->nameIdentifier = $wc->getScreener($data); $result->matchCount = $wc->getDetailsName($result->nameIdentifier)->unresolvedMatchCount; $params = array( 'idClient' => $param->idClient, 'login' => $param->login, 'nameIdentifier' => $result->nameIdentifier, 'matchCount' => $result->matchCount, 'name' => $param->dirNom, 'siren' => $param->Siren, 'nameType' => $param->dirType, 'dateInsert' => date('Y-m-d') ); $sql = $this->insert($params); } return $result; } /** * Return matchCount of name * @param object $data (Nom, Prenom, Societe, Type) * @return int */ public function getCount($data) { if (isset($data->Societe) && $data->Societe!='') { $nameType = 'ORGANISATION'; $name = $data->Societe; } else { $nameType = 'INDIVIDUAL'; $name = $data->Nom; } $sql = $this->select() ->where("name='".$name."' AND nameType='".$nameType."' AND LEFT(nameIdentifier, 3)='so_'") ->group('name'); if ($this->fetchRow($sql)) { $result=$this->fetchRow($sql); return $result->matchCount; } return false; } }