| | |
| | | } |
| | | |
| | | static function cache_add($kod, &$dane) { |
| | | if($dane['od2']) { |
| | | $dane['od'] = $dane['od2']; |
| | | unset($dane['od2']); |
| | | } |
| | | self::$cache[(int)$kod] = $dane; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | static function cache_update($kod) { |
| | | $dane = db2::escape_data(sql::fetchone(sql::query('SELECT *, (SELECT MAX(`od`) FROM `pozycz` WHERE `pozycz`.`id`=`ksiazki`.`id`) as `od2`, (SELECT `do` FROM `pozycz` WHERE `pozycz`.`id`=`ksiazki`.`id` AND `od`=`od2`) as `do`, (SELECT `kto` FROM `pozycz` WHERE `pozycz`.`id`=`ksiazki`.`id` AND `od`=`od2`) as `kto` FROM `ksiazki` WHERE `id`=\''.sql::escape($kod).'\''))); |
| | | $dane = db2::escape_data(sql::fetchone(sql::query('SELECT `ksiazki`.*, `pozycz`.`od`, `pozycz`.`kto` FROM `ksiazki` LEFT OUTER JOIN `pozycz` ON `pozycz`.`id`=`ksiazki`.`id` WHERE `ksiazki`.`id`='.sql::escape($kod)))); |
| | | self::cache_add($kod, $dane); |
| | | } |
| | | } |
| | | |
| | | class ksiazki extends ksiazki_cache { |
| | | static $LT_API = ''; |
| | | |
| | | static function okladka($KOD, $ISBN) { |
| | | return okladki::znajdz($KOD, $ISBN, 'covers'); |
| | | } |
| | |
| | | if($dane['ISBN']) { |
| | | $t = validate::type($dane['ISBN']); |
| | | if($t!='ISBN') { |
| | | error::add('W polu ISBN znajduje się '.$t); |
| | | errorclass::add('W polu ISBN znajduje się '.$t); |
| | | } |
| | | } |
| | | if($dane['ISSN']) { |
| | | $t = validate::type($dane['ISSN']); |
| | | if($t!='ISSN') { |
| | | error::add('W polu ISSN znajduje się '.$t); |
| | | errorclass::add('W polu ISSN znajduje się '.$t); |
| | | } |
| | | } |
| | | |
| | |
| | | $old = self::szukaj_KOD($kod); |
| | | |
| | | if($dane['id']=='' OR empty($dane['autor']) OR empty($dane['tytul']) OR empty($dane['jezyk'])) { |
| | | error::add('Brak wymaganych danych o książce (kod, autor, tytuł, język)'); |
| | | errorclass::add('Brak wymaganych danych o książce (kod, autor, tytuł, język)'); |
| | | } |
| | | |
| | | if($dane['nid']!='') { |
| | |
| | | if($dane['ISBN']) { |
| | | $t = validate::type($dane['ISBN']); |
| | | if($t!='ISBN') { |
| | | error::add('W polu ISBN znajduje się '.$t); |
| | | errorclass::add('W polu ISBN znajduje się '.$t); |
| | | } |
| | | } |
| | | if($dane['ISSN']) { |
| | | $t = validate::type($dane['ISSN']); |
| | | if($t!='ISSN') { |
| | | error::add('W polu ISSN znajduje się '.$t); |
| | | errorclass::add('W polu ISSN znajduje się '.$t); |
| | | } |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | if($dane['do']) { |
| | | $num = db2::num('pozycz', 'id', array('do' => NULL)); |
| | | if($num==0) { |
| | | $num = db2::num('pozycz', 'id'); |
| | | if($num == 0) { |
| | | $ret = array(); |
| | | } |
| | | else |
| | | { |
| | | $ret = db2::get(array('pozycz', array('J', 'ksiazki', 'USING', 'id')), '*', array('do' => NULL), $order, $start, $limit); |
| | | $ret = db2::get(array('pozycz', array('J', 'ksiazki', 'USING', 'id')), '*', NULL, $order, $start, $limit); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | $num = db2::num('ksiazki', 'id', $where); |
| | | if($num==0) { |
| | | if($num == 0) { |
| | | $ret = array(); |
| | | } |
| | | else |
| | | { |
| | | $where = db2::__combine_where($where, TRUE); |
| | | $ret = db2::escape_data(sql::fetch(sql::query('SELECT *, (SELECT MAX(`od`) FROM `pozycz` WHERE `pozycz`.`id`=`ksiazki`.`id`) as `od2`, (SELECT `do` FROM `pozycz` WHERE `pozycz`.`id`=`ksiazki`.`id` AND `od`=`od2`) as `do`, (SELECT `kto` FROM `pozycz` WHERE `pozycz`.`id`=`ksiazki`.`id` AND `od`=`od2`) as `kto`'.(db2::revelance() ? ', '.db2::$revelance : '').' FROM `ksiazki`'.$where.db2::__combine_order($order, TRUE).db2::__combine_limit($start, $limit)))); |
| | | $ret = db2::escape_data(sql::fetch(sql::query('SELECT `ksiazki`.*, `pozycz`.`od`, `pozycz`.`kto`'.(db2::revelance() ? ', '.db2::$revelance : '').' FROM `ksiazki` LEFT OUTER JOIN `pozycz` ON `pozycz`.`id`=`ksiazki`.`id` '.$where.db2::__combine_order($order, TRUE).db2::__combine_limit($start, $limit)))); |
| | | } |
| | | } |
| | | |
| | |
| | | return array($num, $ret, db2::revelance()); |
| | | } |
| | | } |
| | | ?> |
| | | ?> |