
utilizar un campo que se origina de una variable para hacer un insert
Publicado por rafael (1 intervención) el 02/01/2019 16:27:00
/*Esto no logro hacerlo con LARAVE QUERY BUILDER*/
LO HE INTENTADO ASI : pero envia msg de error:
Column not found: 1054 Unknown column '6' in 'field list' (SQL: select `6` as `id_cajero`, `id`, `1` as `id_cajero` from `rel_payment_template` where (`estatus_de_cobro` = COBRADO and `consecutivo_cobro_cajera` > 0 and `id_cortes_caja` = 0 and `estado` = A and `id_cajero` = 1))
1
2
3
4
5
6
7
8
9
10
<?php
$id_corte=25;
$sql="insert into cortes_detalle (id_corte,id_pago)
select $id_corte as id_corte, id_pago from pagos where estado=1 and id_corte=0";
$rs=mysqli_query($link,$sql);
?>
LO HE INTENTADO ASI : pero envia msg de error:
Column not found: 1054 Unknown column '6' in 'field list' (SQL: select `6` as `id_cajero`, `id`, `1` as `id_cajero` from `rel_payment_template` where (`estatus_de_cobro` = COBRADO and `consecutivo_cobro_cajera` > 0 and `id_cortes_caja` = 0 and `estado` = A and `id_cajero` = 1))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
DB::table('cortes_detalle')
->insert(
(array) DB::table('rel_payment_template')
->where([
['estatus_de_cobro', '=', 'COBRADO'],
['consecutivo_cobro_cajera', '>', 0],
['id_cortes_caja', '=', 0],
['estado', '=', 'A'],
['id_cajero', '=', $userid ]
])
->select(
" {$id_corte} as id_cajero",
"id",
"$userid as id_cajero"
)
->get()
);
Valora esta pregunta


0