John Davidson

php - Laravel binding params

0 comments
Message:


I am using below query to get results of 4 id's, but it shows only one result


$id = array(6,7,8,9);      
$params = array(
'connection' => 'redis',
'id' => implode(',',$id)
);

$result = DB::select(
DB::raw("
SELECT
*
FROM
failed_jobs
WHERE
id IN (:id) AND
connection = :connection
"), $params);


My Answer:
DB::connection('mysql')->select("SELECT * FROM table WHERE id IN (?)", [$id]);

Rate this post

3 of 5 based on 8856 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us