Guys i need help I converted my php pure code to laravel but it seems a problem

0 votes

This is pure code :

  1. public function getComments() {
  2.         $query = $this->con->prepare("SELECT * FROM comments WHERE videoId=:videoId AND responseTo=0 ORDER BY datePosted DESC");
  3.         $query->bindParam(":videoId", $id);
  4.         $id = $this->getId();
  5.         $query->execute();
  6.         $comments = array();
  7.         while($row = $query->fetch(PDO::FETCH_ASSOC)) {
  8.             $comment = new Comment($this->con, $row, $this->userLoggedInObj, $id);
  9.             array_push($comments, $comment);
  10.         }
  11.         return $comments;
  12.     }
This is laravel code:
  1. public function getComments() {
  2.         $id = $this->getId();
  3.          $query= DB::table('comments' )->where(['videoId' => $id ,'responseTo' =>0])->get();
  4.         $comments = array();
  5.         while( $row = $query) {
  6.             $comment = new Comment($row, $this->userLoggedInObj, $id);
  7.             array_push($comments, $comment);
  8.         }
  9.         return $comments ;
  10.     }

Probably the problem withe
 FETCH_ASSOC
How can i use FETCH_ASSOC in laravel ? I think get() it use it manually

Sep 17, 2020 in Web Development by Hawati
• 120 points

edited Sep 18, 2020 by Gitika 858 views

Hello @Hawati ,

I think First() is fetch assoc. Try using that first

Hope it helps!

Thank you so much buddy.....I fix that...but now I got an error... FatalErrorException in ProviderRepository.php line 146: Class 'Artisaninweb\SoapWrapper\ServiceProvider' not found

Help me to fix this...

The error is telling you the class can't be found, so perhaps your setup is lacking something or the package didn't install properly. You could try composer dump-autoload and double checking the Soap package is installed properly by checking your composer files  it should be in composer.json and autoload_classmap.php and if that fails double check the steps for installation.

Thank you so much.it helps

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Web Development

0 votes
0 answers

@edureka! in my nodejs as its i have used it and pug also but my css doesn't worked as while running localhost it doesn't show styling of css

<!DOCTYPE html><html></html><head><style></style>@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); *{ margin: 0; box-sizing: border-box; padding: 0; } #navbar{ background-color:black; padding: 18px ...READ MORE

Jun 11, 2020 in Web Development by anonymous
• 120 points
1,148 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How can i create transparency to my images?

The transparency of image can be done ...READ MORE

answered Jan 30, 2020 in Web Development by Niroj
• 82,840 points
818 views
0 votes
1 answer

How to track with Google Analytics on a redirection page with PHP?

Hello @kartik, Since the page that is sending ...READ MORE

answered Jul 7, 2020 in Web Development by Niroj
• 82,840 points
1,839 views
0 votes
1 answer

How to create a laravel hashed password?

Hello @kartik, Hashing A Password Using Bcrypt in Laravel: $password ...READ MORE

answered Oct 6, 2020 in Web Development by Niroj
• 82,840 points
13,459 views
0 votes
0 answers

Javascript/Jquery - how to replace a word but only when not part of another word?

I am currently doing a regex comparison ...READ MORE

Aug 22, 2022 in Web Development by gaurav
• 23,260 points
671 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP