app/Console/Commands/UpdateLocation.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle(){
        $this->info('Starting loading ...');
        for(;;){
            $results = DB::select("SELECT * FROM queue_classifieds
                       STRAIGHT_JOIN classifieds ON (id = cla_id)
                       LIMIT 1");
            if(!$results)break;
            foreach($results as $row){
                $keyword = $row->cla_address;
                exit();
                $arrLoc = ["catid" => $row->cla_cat_id];
                $myDetect = new \Toanld\Location\DetectLocation($keyword);
                $arrLoc["citid"] = $myDetect->getCity();
                $arrLoc["disid"] = $myDetect->getDistrict();
                $arrLoc["wardid"] = $myDetect->getWard();
                $arrLoc["streetid"] = $myDetect->getStreet();
                $arrLoc["projid"] = $myDetect->getProject($row->cla_title);
                $update = [];
                $update["cla_citid"] = $arrLoc["citid"];
                $update["cla_disid"] = $arrLoc["disid"];
                $update["cla_wardid"] = $arrLoc["wardid"];
                $update["cla_streetid"] = $arrLoc["streetid"];
                $update["cla_projid"] = $arrLoc["projid"];
                /
                $links = new \Toanld\MakeLink\MakeLink($arrLoc);
                $update["cla_linid"] = $links->createLink();
                print_r($update);
                DB::table('classifieds')
                    ->where('cla_id',$row->cla_id)
                    ->update($update);
                DB::table('queue_classifieds')
                    ->where('id',$row->cla_id)
                    ->delete();
            }
            DB::disconnect('foo');
            app()->make("SphinxConnect")->close();
        }
        $this->info('Update finish!!!');
    }
public function handle ( ) { $ this -> info ( 'Starting loading ...' ) ; for ( ; ; ) { $ results = DB :: select ( " SELECT * FROM queue_classifieds
                       STRAIGHT_JOIN classifieds ON (id = cla_id)
                       LIMIT 1 " ) ; if ( ! $ results ) break ; foreach ( $ results as $ row ) { $ keyword = $ row -> cla_address ; $ arrLoc = [ " catid " => $ row -> cla_cat_id ] ; $ myDetect = new \ Toanld \ Location \ DetectLocation ( $ keyword ) ; $ arrLoc [ " citid " ] = $ myDetect -> getCity ( ) ; $ arrLoc [ " disid " ] = $ myDetect -> getDistrict ( ) ; $ arrLoc [ " wardid " ] = $ myDetect -> getWard ( ) ; $ arrLoc [ " streetid " ] = $ myDetect -> getStreet ( ) ; $ arrLoc [ " projid " ] = $ myDetect -> getProject ( $ row -> cla_title ) ; $ update = [ ] ; $ update [ " cla_citid " ] = $ arrLoc [ " citid " ] ; $ update [ " cla_disid " ] = $ arrLoc [ " disid " ] ; $ update [ " cla_wardid " ] = $ arrLoc [ " wardid " ] ; $ update [ " cla_streetid " ] = $ arrLoc [ " streetid " ] ; $ update [ " cla_projid " ] = $ arrLoc [ " projid " ] ; $ links = new \ Toanld \ MakeLink \ MakeLink ( $ arrLoc ) ; $ update [ " cla_linid " ] = $ links -> createLink ( ) ; print_r ( $ update ) ; DB :: table ( 'classifieds' ) -> where ( 'cla_id' , $ row -> cla_id ) -> update ( $ update ) ; DB :: table ( 'queue_classifieds' ) -> where ( 'id' , $ row -> cla_id ) -> delete ( ) ; } DB :: disconnect ( 'foo' ) ; app ( ) -> make ( " SphinxConnect " ) -> close ( ) ; } $ this -> info ( 'Update finish!!!' ) ; }
Execute the console command.
Execute the console command .
//$results = collect($results); //_debug($row); //$keyword = 'Dự án Hà Nội Homeland, Phường Thượng Thanh, Long Biên, Hà Nội'; //_debug($row);exit(); //                echo $keyword . '<hr>'; // create a SphinxQL Connection object to use with SphinxQL //* //                print_r($arrLoc); //*/