Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z wartościami domyślmymi
pgrzelka
post
Post #1





Grupa: Zarejestrowani
Postów: 313
Pomógł: 24
Dołączył: 9.08.2008
Skąd: Kielce

Ostrzeżenie: (0%)
-----


Witam

posiadam tabelę
  1. CREATE TABLE IF NOT EXISTS `content` (
  2. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `author_id` int(10) UNSIGNED DEFAULT NULL,
  4. `modified_by` int(10) NOT NULL DEFAULT '0',
  5. `lang_id` int(11) NOT NULL DEFAULT '1',
  6. `title` varchar(250) DEFAULT NULL,
  7. `date_add` datetime DEFAULT NULL,
  8. `date_mod` datetime DEFAULT NULL,
  9. `date_start` date DEFAULT NULL,
  10. `date_expire` date DEFAULT NULL,
  11. `is_expired` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  12. `template` varchar(150) DEFAULT NULL,
  13. `price` float DEFAULT NULL,
  14. `visible` tinyint(1) DEFAULT '1',
  15. `is_accepted` tinyint(1) NOT NULL DEFAULT '1',
  16. `chat` tinyint(1) DEFAULT NULL,
  17. `expand` tinyint(1) NOT NULL DEFAULT '0',
  18. `commentable` tinyint(1) DEFAULT '0',
  19. `exportable` tinyint(1) DEFAULT '0',
  20. `content_type` enum('books','gallery','almanac','article','external') DEFAULT NULL,
  21. `searchable` text NOT NULL,
  22. `is_featured` tinyint(1) DEFAULT '0',
  23. `content_image` varchar(100) DEFAULT NULL,
  24. `content_image_id` int(5) UNSIGNED DEFAULT NULL,
  25. PRIMARY KEY (`id`),
  26. KEY `content_lang_admin` (`author_id`)
  27. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;


dla kolumny 'visible' ustalona jest domyślna wartość 1,
czemu jeśli dodaje rekord z visible='' to wyskakuje błąd?
czemu na innym serwerze mysql identyczna funkcja i baza danych działa bez problemu?


--------------------
Go to the top of the page
+Quote Post
skowron-line
post
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

Ostrzeżenie: (0%)
-----


A jaki błąd się wyświetla.?


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
pgrzelka
post
Post #3





Grupa: Zarejestrowani
Postów: 313
Pomógł: 24
Dołączył: 9.08.2008
Skąd: Kielce

Ostrzeżenie: (0%)
-----


Kod
                SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'visible' at row 1 in "INSERT INTO `content` (`author_id`, `modified_by`, `lang_id`, `title`, `date_add`, `date_mod`, `date_start`, `date_expire`, `is_expired`, `template`, `price`, `visible`, `is_accepted`, `chat`, `expand`, `commentable`, `exportable`, `content_type`, `searchable`, `is_featured`, `content_image`, `content_image_id`) VALUES (?, ?, ?, ?, NOW(), NOW(), NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"


wiem że tam pisze że jest niepoprawna wartość dla kolumny Visible,
ale czemu na innym serwerze to działa?
(nie znam konfiguracji tamtego serwera, ewentualnie mogę podać mojego)


--------------------
Go to the top of the page
+Quote Post
skowron-line
post
Post #4





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

Ostrzeżenie: (0%)
-----


Będę strzelał ale możliwe że wersja mysql na którym stała baza poprzednio pozwalał na podawanie wartośći domyślnych jako string nie jako liczbę
pewnie jak zmienisz
  1. DEFAULT '0' -> DEFAULT 0

to będzie działać.


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 23:23