MC_ Posted June 6, 2005 Report Share Posted June 6, 2005 ir MySQL tabula, kas sevii reprezentee calendaara datus: | id | event_date | event_text | id int(11) unsigned not null auto_increment PRIMARY KEY event_date - datetime event_text - text Ar 1 SQL vaicaajumu nepiecieshams ieguut visus konkreetaas dienas CURENT_DATE() ieraxtus sakaartotus no 7:00 - 23:00 ar 1 h intervaalu. Vajag izvadiit arii taadus ieraxtus, kuri reaali neexistee. piem izvade vareetu buut shada: 7:00 - "" 8:00 - "Superiigaas brokastis" 9:00 - "Superiigais darbs" 10:00 - "" .... 22:00 - "" 23:00 -"" Jau ieprieksh pateicos.. :) Link to comment Share on other sites More sharing options...
Delfins Posted June 6, 2005 Report Share Posted June 6, 2005 nu nebūs tā kā tu gribi... varbūt i var... bet labāk to 7.00 .. 23.00 ar `neeksistējošiem` realizēt iekš PHP. select date_format( event_date, '%H' ) as stunda , event_text from events // Init for( $i=7; $i<24; $i++ ) { $eventi[$i] = ''; } // Read DB while ( $row ) { $eventi[(int)$row->stunda] .= '<p>'.$row->event_text . '</p>'; } Vienkārši ir lietas, kuras nevajag pārgudri mudrīt... Link to comment Share on other sites More sharing options...
MC_ Posted June 6, 2005 Author Report Share Posted June 6, 2005 Delfins tu jau koju laikos negribeeji domaat. slinks maita. ;) neticu ka nevar ar SQL.. ar PHP man neder emm...UNION tmp_tabula ar laikiem..emmm.. ziimeejam uz lapas un modeleejam Link to comment Share on other sites More sharing options...
Venom Posted June 6, 2005 Report Share Posted June 6, 2005 piekritu Delfinam vai nu arī jāraksta monstrīgs sql vaicājums, kas izskatītos kā select stunda, visi eventi starp stundas sākumu un beigām savienot ..... Link to comment Share on other sites More sharing options...
bubu Posted June 6, 2005 Report Share Posted June 6, 2005 (edited) Ja jau ļoti vajag SQLā, tad: select tmp.tim, IFNULL(event_text, _utf8"") from (select '07:00' as tim union select '08:00' as tim union select '09:00' as tim union select '10:00' as tim union select '11:00' as tim union select '12:00' as tim union select '13:00' as tim union select '14:00' as tim union select '15:00' as tim union select '16:00' as tim union select '17:00' as tim union select '18:00' as tim union select '19:00' as tim union select '20:00' as tim union select '21:00' as tim union select '22:00' as tim union select '23:00') tmp LEFT JOIN events ON DATE_ADD(CURDATE(), INTERVAL tmp.tim HOUR_MINUTE) <= event_date AND DATE_ADD(DATE_ADD(CURDATE(), INTERVAL tmp.tim HOUR_MINUTE), INTERVAL 1 HOUR) > event_date ORDER BY tmp.tim bet personīgi es izvēlētos Delfina risinājumu. Edited June 6, 2005 by bubu Link to comment Share on other sites More sharing options...
Delfins Posted June 6, 2005 Report Share Posted June 6, 2005 Delfins tu jau koju laikos negribeeji domaat. slinks maita. ;) neticu ka nevar ar SQL.. ar PHP man neder emm...UNION tmp_tabula ar laikiem..emmm.. ziimeejam uz lapas un modeleejam 18303[/snapback] ja PHP nevar, tad lietojam storētas proc., par kurām iekš mysql es neko nezinu. zinu ka oracle/pgsql to varēs :) Vienkārši ir jāizvēlās, kur tiks ielikta loģika - vai nu db vai aplikācijā. Mysql manuprāt nebūs tas īstais, kur likt iekšā funkcionalitāti. PS: neesmu slinks, vienkārši daru tā kā ir labāk. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted June 6, 2005 Report Share Posted June 6, 2005 man skjit ka ieksh MYSQL tas pieprasijums buus monsteriigs :( kaapeec gan ne ieksh PHP - vel jo vairaak spriezot peec tavas DB tev pilniigi tukshi (NULL) lauki vienkaarshi nav :) taa kaa savaac visus ierakstus (vajadziigaa datuma un ar PHP ciklu izvadi :) ) eerti leeti vienkaarshi :) Link to comment Share on other sites More sharing options...
Recommended Posts