Questa query restituisce null quando è previsto un oggetto.Laravel! = Operatore in cui non funziona
$vow = DB::table('media_featured')->where('is_video_of_the_week', 1)->
where('video_of_week_expired', '!=', 1)->first();
CREATE TABLE `media_featured` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`media_id` int(10) unsigned DEFAULT NULL,
`is_video_of_the_week` tinyint(1) DEFAULT NULL,
`is_featured` tinyint(1) DEFAULT NULL,
`video_of_week_expired` tinyint(1) DEFAULT NULL,
`featured_expired` tinyint(1) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `media_featured_media_id_foreign` (`media_id`),
CONSTRAINT `media_featured_media_id_foreign` FOREIGN KEY (`media_id`) REFERENCES `media` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Un record potrebbe avere is_video_of_the_week = 1
e video_of_week_expired = NULL
ma la query precedente restituisce null.
Qualche idea?
Quanto sopra ha funzionato per me prima di pubblicare su SO. Sto pianificando di contrassegnare la colonna come is_expired = 1 una volta che non è più presente, è per questo che ho voluto confrontarmi con non = 1 invece di whereNull, ma suppongo che dovrò fare attenzione nell'esecuzione del codice? – egekhter
@egekhter: ok, allora? – zerkms
Ha senso, grazie per la direzione. – egekhter