P
P
pyatin2012-07-25 13:58:49
MySQL
pyatin, 2012-07-25 13:58:49

INSERT SELECT in Yii?

How to make such a request

INSERT INTO users_log (id, email)<br>
SELECT id, email FROM users<br>

With AR?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Makarov, 2012-07-25
@pyatin

Yii::app()->db->createCommand(
  "INSERT INTO users_log (id, email)
    SELECT id, email FROM users"
)->execute();

A
Anatoly, 2012-07-25
@taliban

No way, choose separately give AR and she inserts.

M
Mikhail Osher, 2012-07-25
@miraage

ActiveRecord was conceived for other purposes. Think about the name "ActiveRecord" - an active record. That is, operations are preferably with one record - reading, writing, selecting by foreign keys, deleting, etc.
Your idea is clear, such things are done by direct request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question