Closed CoderPoet closed 6 years ago
你实体代码贴出来 @CoderPoet
@stelin
namespace App\Models\Entity;
use Swoft\Db\Model;
use Swoft\Db\Bean\Annotation\Column;
use Swoft\Db\Bean\Annotation\Entity;
use Swoft\Db\Bean\Annotation\Id;
use Swoft\Db\Bean\Annotation\Required;
use Swoft\Db\Bean\Annotation\Table;
use Swoft\Db\Types;
/**
*
*
* @Entity()
* @Table(name="test")
* @uses Test
* @version 2018年03月19日
*/
class Test extends Model
{
/**
* @var int $id
* @Id()
* @Column(name="id", type=Types::INT)
*/
private $id = '';
/**
* @var string $test1
* @Column(name="test1", type=Types::STRING, length=32)
*/
private $test1 = '';
/**
* @var int $test2
* @Column(name="test2", type=Types::INT)
*/
private $test2 = '';
/**
* setId
*
* @param int $value
*
* @return $this
*/
public function setId(int $value)
{
$this->id = $value;
return $this;
}
/**
* setTest1
*
* @param string $value
*
* @return $this
*/
public function setTest1(string $value): self
{
$this->test1 = $value;
return $this;
}
/**
* setTest2
*
* @param int $value
*
* @return $this
*/
public function setTest2(int $value): self
{
$this->test2 = $value;
return $this;
}
/**
* getId
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* getTest1
*
* @return string
*/
public function getTest1()
{
return $this->test1;
}
/**
* getTest2
*
* @return int
*/
public function getTest2()
{
return $this->test2;
}
}
@stelin 表之前删掉了 ,重新建了一个, 脚手架生成了一下。
private $test2 = ''; 是int,但是你默认值空字符串 @CoderPoet
@stelin 啊 没注意看脚手架生成的实体。感谢提醒!
@stelin 建议脚手架生成的实体属性 不要设置默认值 直接 private $test2 就好啦!
已修复,db组件请更新至v1.1.4
Details