问题描述:

i have table with field user_id (unique). i want set manually set it.but when i set it,JTable not insert data.

my $data array is:

$data['user_id']=500;

$data['name']='test';

$data['lastname']='test';

and my code in model is:

$table = $this->getTable();

if ($table->save($data) === true) {

return $table->user_id;}

and my table file is:

 class UserproTableuser extends JTable

{

public function __construct(&$db)

{

parent::__construct('#__userpro_users', 'user_id', $db);

}

}

网友答案:

Try this:

$table->bind($data);
$table->save();
相关阅读:
Top