php-activerecord icon indicating copy to clipboard operation
php-activerecord copied to clipboard

Cannot change $primary_key

Open Keberdle opened this issue 8 years ago • 0 comments

It cannot change $primary_key of entity. After save is still in database original value.

$ended_uniq_customer_actions = \Db\ActionsToCustomersUniq::find('all', array( 'conditions' => array( 'customers_uniq_id = ?', 16728 ) ));

$ended_uniq_customer_actions[0]->customers_uniq_id = 15892; $ended_uniq_customer_actions[0]->save();

class ActionsToCustomersUniq extends ActiveRecord\Model { static $table_name = 'crm_actions_to_customers_uniq'; static $primary_key = array('actions_id','customers_uniq_id'); }

CREATE TABLE IF NOT EXISTS crm_actions_to_customers_uniq ( actions_id int(11) NOT NULL DEFAULT '0', updated_at datetime DEFAULT NULL, created_at datetime DEFAULT NULL, customers_uniq_id int(11) NOT NULL DEFAULT '0', PRIMARY KEY (customers_uniq_id,actions_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -----------------------------+ | actions_id | customers_uniq_id | -----------------------------+ | 3 | 16728 | -----------------------------+

mysql Ver 14.14 Distrib 5.5.53, for debian-linux-gnu (x86_64) using readline 6.3

Thank You in advance for help

Keberdle avatar Feb 20 '17 09:02 Keberdle