当前位置: 动力学知识库 > 问答 > 编程问答 >

components - set manually id for row of table by JTable in joomla

问题描述:

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();
分享给朋友:
您可能感兴趣的文章:
随机阅读: