Witam,
otóż mam problem z dodawaniem rekordu do bazy (nadpisywanie rekordu działa).
Przy "spłukiwaniu" (screen błędu) (IMG:
http://myimg.pl/images/beztytiti.png)
Kod z controllera:
$em = Zend_Registry::get("em");
$account = new Application_Model_Account;
$em->persist($account);
$em->flush();
--
-- Struktura tabeli dla `accounts`
--
CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL DEFAULT '',
`password` varchar(255) NOT NULL,
`premdays` int(11) NOT NULL DEFAULT '0',
`lastday` int(10) UNSIGNED NOT NULL DEFAULT '0',
`email` varchar(255) NOT NULL DEFAULT '',
`key` varchar(20) NOT NULL DEFAULT '0',
`blocked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'internal usage',
`warnings` int(11) NOT NULL DEFAULT '0',
`group_id` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
--
-- Zrzut danych tabeli `accounts`
--
INSERT INTO `accounts` (`id`, `name`, `password`, `premdays`, `lastday`, `email`, `key`, `blocked`, `warnings`, `group_id`) VALUES
(1, '2', '1', 65535, 0, '', '0', 0, 0, 1),
(2, '', '', 0, 0, '', '0', 0, 0, 1);
Model:
<?php
/**
* @Entity
* @Table(name="accounts")
*/
class Application_Model_Account
{
/**
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/** @Column(type="string") */
private $name = "";
/** @Column(type="string") */
private $password = "";
/** @Column(type="integer") */
private $premdays = 0;
/** @Column(type="integer") */
private $lastday = 0;
/** @Column(type="string") */
private $email = "";
/** @Column(type="string") */
private $key = "";
/** @Column(type="integer") */
private $blocked = 0;
/** @Column(type="integer") */
private $warnings = 0;
/** @Column(type="integer") */
private $group_id = 1;
public function __construct() {}
public function setId($id) {
$this->id = $id;
return $this;
}
public function getId() {
return $this->id;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function getName() {
return $this->name;
}
public function setPassword($password) {
$this->password = $password;
return $this;
}
public function getPassword() {
return $this->password;
}
public function setPremdays($premdays) {
$this->premdays = $premdays;
return $this;
}
public function getPremdays() {
return $this->premdays;
}
public function setLastday($lastday) {
$this->lastday = $lastday;
return $this;
}
public function getLastday() {
return $this->lastday;
}
public function setEmail($email) {
$this->email = $email;
return $this;
}
public function getEmail() {
return $this->email;
}
public function setKey($key) {
$this->key = $key;
return $this;
}
public function getKey() {
return $this->key;
}
public function setBlocked($blocked) {
$this->blocked = $blocked;
return $this;
}
public function getBlocked() {
return $this->blocked;
}
public function setWarnings($warnings) {
$this->warnings = $warnings;
return $this;
}
public function getWarnings() {
return $this->warnings;
}
public function setGroupId($group_id) {
$this->group_id = $group_id;
return $this;
}
public function getGroupId() {
return $this->group_id;
}
}
Szukałem błędów, ale nie mam pomysłu. Problem jest z zapytaniem chyba / wartościami, ale nie jestem pewny.