Hello everyone,
I am trying to translate this code:
INSERT INTOapp_user_pruub(cedula, nombre, apellido) SELECT CAMPO01 As cedula,CONCAT( CONCAT(CAMPO02,’ ‘), CAMPO03) As nombre, CONCAT( CONCAT(CAMPO04,’ '), CAMPO05) As apellido FROM app_employees WHERE 1
I want to write it in the Yii framework, I have written this code, but when I execute it, it only copies a quarter of the data.
public function actionProcess(){
$data = Yii::app()->db->createCommand()
->from('app_employees')
->select(['CAMPO01 AS cedula1',"CONCAT(CAMPO02, ' ', CAMPO03) AS name", "CONCAT(CAMPO04, ' ', CAMPO05) AS lastname"])
->queryAll();
foreach($data as $key => $value){
$data2 = Yii::app()->db->createCommand()
->insert(
'app_user_pruub',
[
'cedula'=>$value['cedula1'],
'nombre'=>$value['name'],
'apellido'=>$value['lastname']
]
);
//print_r($value);
//echo '<br>';
}
}
Could someone tell me what’s wrong ?. Thank you.