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 91 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 10, 2020 in Web Development by anonymous
• 120 points
168 views
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,680 points
97 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,680 points
492 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,680 points
161 views
+1 vote
2 answers

How to embed Google map on my website?

1. Search whatever you want to embed. 2. ...READ MORE

answered Jan 17, 2020 in Web Development by anonymous
198 views
0 votes
0 answers

Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

Jan 17, 2020 in Web Development by anonymous
• 37,490 points
170 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21, 2020 in Web Development by Niroj
• 82,680 points

edited Jan 21, 2020 by Niroj 160 views