I have this MySQL insert:
INSERT INTO restaurant (id_restaurant, id_category)
SELECT id_rest, id_cat
FROM restaurant_menu rm, category_menu cm
WHERE rm.name = "discount" AND cm.name = "beach";
but now I want to do this insert in Yii. I know that I can do it using Yii query builder, but I think that if the query/insert/delete/update is very long, that is too complex. Therefore, I would like to know if is possible to use MySQL code into a Yii code directly, I mean, for example something similar to this:
$sql='INSERT INTO restaurant (id_restaurant, id_category) SELECT id_rest, id_cat FROM restaurant_menu rm, category_menu cm WHERE rm.name = "discount" AND cm.name = "beach"'
$command=$connection->createCommand($sql);
Please, someone could show me how to do this insert using the MySQL code directly in Yii?
"for your string, use'for your data. Or better, use placeholder values.