I want to change the name of a column in my database and to do that I have to create a migration and drop a table
The query I want to run is
1 2 3 | UPDATE pallets SET production_date = print_date; |
Seem so simple in SQL but to do it in CakePHP 4 took some finding
Copy data between columns in CakePHP 4
1 2 3 4 5 6 7 | $builder = $this ->getQueryBuilder(); $exp = $builder ->newExpr( 'print_date' ); $statement = $builder ->update( 'pallets' )->set( 'production_date' , $exp ); $statement ->execute(); |
When you debug($statement) you get the following in the Query Object
1 | 'sql' => 'UPDATE pallets SET production_date = (print_date)' |
0 Comments