please help me. I want to ask:
Let say I have 2 tables: user_master and people.
Now I am currently build an application in PHP with Laravel 5.1 framework that select the data from user_master table (with some constraint in where clause) and insert into people table.
The code is :
public function handle() {
$results = DB::select(DB::raw("SELECT * FROM user_master WHERE div_id = 1"));
foreach ($results as $res) {
//saving to array
//insert query to table people here.
}
}
My questions are:
- How to save the result of
selectquery to array, and - Insert that array into
peopletable using RAW query (INSERT INTO people VALUES (...)).
P.S.: My query is RAW query, not using Eloquent. And please provide answer without Eloquent.
Thank you so much for any answer.
->get();method to get result within your$resultvariables