class Dbhelper { // ссылка на объект CI private $CI; // сообщения об ошибках оьработки данных private $messages = array( 'ERROR_TABLE_EMPTY' => 'Произведена попытка создания записи без указания таблицы!', ); public function __construct() { $this->CI = &get_instance(); } public function modify($table, $id, $vars) { if (empty($table) AND !$table = $this->CI->input->post('table__sys')) show_error($this->messages['ERROR_TABLE_EMPTY']); $sql = !$id ? 'INSERT IGNORE INTO ' : 'UPDATE IGNORE '; $sql .= DB_PREFIX.$table.' SET '; if (!empty($vars)) { foreach ($vars as $key => $val) { if (is_array($val)) $sql .= $key.' = '.$val[0].', '; else $sql .= $key.' = '.$this->CI->db->escape($val).', '; } } $sql = substr($sql, 0, strlen($sql) - 2); if ($id) { $sql .= ' WHERE id = '.$this->CI->db->escape($id); } $this->CI->db->query($sql); return $id ? $id : $this->CI->db->insert_id(); } public function delete($table, $id) { $sql = 'DELETE FROM '.DB_PREFIX.$table.' '; $sql .= ' WHERE id = '.$this->CI->db->escape($id); $this->CI->db->query($sql); return true; } public function pages($table, $where = false, $counter = false) { if (!$counter) { $sql = 'SELECT COUNT(*) as counter FROM '.DB_PREFIX.$table.' '; if (!empty($where)) { $sql .= 'WHERE '; foreach ($where as $key => $val) if ($key == 'ids') $sql .= ' id IN ('.$val.') AND '; elseif (is_array($val) AND !empty($val[1])) $sql .= $key.' '.$val[1].' '.$this->CI->db->escape($val[0]).' AND '; elseif (is_array($val) AND !empty($val[2])) $sql .= $key.' '.$val[2].' '.$val[0].' AND '; elseif (is_array($val)) $sql .= $key.' = '.$val[0].' AND '; else $sql .= $key.' = '.$this->CI->db->escape($val).' AND '; $sql = substr($sql, 0, strlen($sql) - 4); } $array['count'] = $this->CI->db->query($sql)->single('counter'); } else { $array['count'] = $counter; } if (substr($array['count'], -1, 1) == 1 AND substr($array['count'], -2, 2) != 11) { $array['mtext'] = 'учреждение'; } elseif (substr($array['count'], -1, 1) == 2 AND substr($array['count'], -2, 2) != 12) { $array['mtext'] = 'учреждения'; } elseif (substr($array['count'], -1, 1) == 3 AND substr($array['count'], -2, 2) != 13) { $array['mtext'] = 'учреждения'; } elseif (substr($array['count'], -1, 1) == 4 AND substr($array['count'], -2, 2) != 14) { $array['mtext'] = 'учреждения'; } else { $array['mtext'] = 'учреждений'; } if (!$array['limit'] = $this->CI->ModSettings->getArray('limit')) $array['limit'] = $this->CI->ModSettings->get('PAGE_LIMIT'); $array['page'] = $this->CI->ModSettings->getArray('page') ? $this->CI->ModSettings->getArray('page') : 1; $array['total'] = ceil($array['count']/$array['limit']); if (!$array['total']) $array['total'] = 1; if ($array['page'] > $array['total']) $array['page'] = $array['total']; $array['start'] = $array['page'] * $array['limit'] - $array['limit']; $array['query'] = 'LIMIT '.$array['start'].','.$array['limit']; $array['nums'] = $this->counter($array['page'], $array['total'], $array['limit']); return $array; } public function sorting($id, $dir, $table) { $sql = 'SELECT sorting FROM '.DB_PREFIX.$table.' '; $sql .= 'WHERE id = '.$this->CI->db->escape($id); $sorting = $this->CI->db->query($sql)->single('sorting'); if ($dir == 1) { $sorting = $sorting + 1; $sql = 'UPDATE '.DB_PREFIX.$table.' SET '; $sql .= 'sorting = (sorting+1) '; $sql .= 'WHERE id = '.$this->CI->db->escape($id); $this->CI->db->query($sql); } if ($dir == 2) { $sorting = $sorting - 1; $sql = 'UPDATE '.DB_PREFIX.$table.' SET '; $sql .= 'sorting = (sorting-1) '; $sql .= 'WHERE id = '.$this->CI->db->escape($id); $this->CI->db->query($sql); } return $sorting; } public function sortingQuery() { $sorting = $this->CI->ModSettings->get('SORTING'); $direction = $this->CI->ModSettings->get('SORTING_DIRECTION'); if ($getsorting = $this->CI->ModSettings->getArray('sorting')) $sorting = $getsorting; if ($getdirection = $this->CI->ModSettings->getArray('direction')) $direction = $getdirection; if (!empty($sorting)) return $sorting.' '.$direction.' '; } function counter($pc=1,$pa=10,$pp=15) { $r = array(); if ($pa<=$pp) { for ($i=1;$i<=$pa;$i++) { $r[$i] = $i; } } else { $b = $pc-floor($pp/2); if ( $pp%2==0) $b++; if ( $b<1 ) $b = 1; if ( $b+$pp > $pa) $b = $pa-$pp+1; for ($i=1;$i<=$pp;$i++) $r[$i] = $b++; if ( $r[1]!=1 ) { $r[1] = 1; $r[2] = '...'; } if ( $r[$pp]!=$pa ) { $r[$pp] = $pa; $r[$pp-1] = '...'; } } return $r; } }
Engine error: Cannot modify header information - headers already sent by (output started at /home/ekalejimas/public_html/components/common/libraries/Dbhelper.php:204)
Module: codeigniter/Common.php
Line: 387
Non-existent class: Dbhelper