Select data from one table in database1 and insert into another table in database2

Guys please guide me to take a particular row of records from table1 on local database and insert into table1 on remote database.

  1. select row from table 1.
  2. Insert row into table 2.

Check the official guide on how to do basic DB operations.

1 Like

Yes ,

My problem is Yii only accepts this kind of array

$values = array (
‘id’ => ‘7’,
‘user_type’ => ‘2’,
‘email_id’ => ‘staff@emperic.co’,
‘password’ => ‘8cb2237d0679ca88db6464eac60da96345513964’,
‘is_logged_in’ => ‘1’,
‘created_date’ => ‘2018-10-03 11:52:21’,
‘status’ => ‘1’
);
But I got my select result array like below yii is not accept this arrray as value

$values = Array (
[id] => 1
[user_type] => 1
[email_id] => fori@care.com
[password] => 8cb2237d0679ca88db6464eac60da96345513964
[is_logged_in] => 1
[created_date] => 2018-10-04 11:21:08
[status] => 1
);

Yii::app()->dbb->createCommand()->insert(‘user’,$values);

Well, form new array from another array.

I don’t see why not. You haven’t presented enough information for us to see what you’re doing wrong.

Btw: SHA-1(“12345”) = 8cb2237d0679ca88db6464eac60da96345513964

So don’t use that password. And SHA-1 hashing is not secure for password storage.

1 Like

I tried a lot but i can’t form an array like this using PHP.

$values = array (
‘id’ = ‘7’,
‘user_type’ = ‘2’,
‘email_id’ = ‘staff@emperic.co’,
‘password’ = ‘8cb2237d0679ca88db6464eac60da96345513964’,
‘is_logged_in’ = ‘1’,
‘created_date’ = ‘2018-10-03 11:52:21’,
‘status’ = ‘1’
);

is there any option to form an array using yii

Thanks for your information Fsb.

In PHP, = is the assignment operator, so the above code says to assign the value "7" to the string "id". You can’t assign to a string literal in PHP so it doesn’t compile. In PHP you assign to variables and to object properties.

Read about arrays here.

I guess what you really want is something like

$values = array(
    'id' => 7,
    'user_type' => 2,
    ...
);

Notice the => token separating key from value.

Exactly Fsb is it possible to do in php using loop to create an array like this.

$values = array(
‘id’ => 7,
‘user_type’ => 2,

);

Sure it’s possible: http://php.net/manual/en/langref.php

Thank You Sam

hello, can you give me a reference to the code that adds data to a table in another db