fetching result from DB

Posted 6 months ago by seantiago24

CREATE TABLE sondage ( sondage_id int(11) NOT NULL, sondage_question varchar(255) NOT NULL, Sondage_date_debut datetime NOT NULL, sondage_date_fin datetime NOT NULL, sondage_voters int(11) NOT NULL, sondage_votes float NOT NULL, created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE sondage_reponse ( reponse_id int(11) NOT NULL, reponse_sondage_id int(11) NOT NULL, reponse_reponse varchar(255) NOT NULL, created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE vote ( vote_id int(11) NOT NULL, vote_question_id int(11) NOT NULL, vote_reponse_id int(11) NOT NULL, created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

                $this->today = date('Y-m-d');
                $startDate = $this->today." 00:00:00";
                $endDate = $this->today." 23:59:59";

                $votes = DB::table('vote')->where('vote_question_id', $question_id)
                ->join('sondage', 'sondage.sondage_id' ,'vote.vote_question_id')
                ->join('sondage_reponse' ,'sondage_reponse.reponse_id' ,'vote.vote_reponse_id' )
                ->where('Sondage_date_debut' ,'<=', $this->today)
                ->where('Sondage_date_fin','>=' ,$this->today)
                ->get();

hi i'm trying to create a vote system , but always getting an error with the query , knowing that t should not use any library and using DB query not eloquent , plz someone help to fetch my result : showing the question and it's responses and the count of persons that voted on that question it's urgent plzz

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.