$this->db->group_start(); $this->db->where('contracts_id_client_purchaser', $id_client); $this->db->or_where('contracts_id_client_supplier', $id_client); $this->db->group_end(); $this->db->where('contracts_active', 1); $this->db->order_by('id_contracts', 'desc'); $query = $this->db->get('contracts');
log_message('error', 'Some variable did not contain a value.');
Źródło: https://codeigniter.com/userguide3/general/errors.html
$this->db->where('user_status', NULL); $query_1 = $this->db->get_compiled_select('users'); $this->db->where('user_status', 'inactive'); $query_2 = $this->db->get_compiled_select('users'); $query_union = $this->db->query($query_1 . " UNION " . $query_2);
https://stackoverflow.com/questions/2040655/union-query-with-codeigniters-active-record-pattern
vim system/helpers/url_helper.php
Change this:
function current_url() { $CI =& get_instance(); return $CI->config->site_url($CI->uri->uri_string()); }
into that:
function current_url() { $CI =& get_instance(); return $CI->config->site_url($CI->uri->uri_string()). (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); }
W php 7.4 jest problem jeśli w treści komórki wstawiamy integer.
Daje wówczas taki błąd:
Severity: Notice Message: Trying to access array offset on value of type int Filename: Cell/DefaultValueBinder.php
Trzeba go zamienić na string i jest ok.
Było:
'A' . $cell_index => array($lp),
Ma być:
'A' . $cell_index => array(strval($lp)),
W Codeigniterze (a właściwie w samym php) występuje pewien problem z apostrofami jeśli są zapisywane w bazie i ponownie wyświetlane w polu input w formularzu.
Jako przykładu użyję pola Model w bazie Samochody.
Zobacz całość
Domyślnie w UTF-8 sortowanie ustawia literę "Ł" na końcu listy.
Aby to zmienić należy zmienić COLLATION przy ORDER BY na 'utf8_polish_ci'.
Zmiany należy dokonać w pliku:
system/database/DB_query_builder.phg
było
$qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE)) ? array('field' => ltrim(substr($field, 0, $match[0][1])), 'direction' => ' '.$match[1][0], 'escape' => TRUE) : array('field' => trim($field), 'direction' => $direction, 'escape' => TRUE);
ma być
$qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE)) ? array('field' => ltrim(substr($field, 0, $match[0][1])), 'direction' => ' '.$match[1][0], 'escape' => TRUE) : array('field' => trim($field), 'direction' => 'COLLATE utf8_polish_ci '.$direction, 'escape' => TRUE);
WAŻNE! Nie działa jeśli sortujemy liczby!
Przy wywołaniu zadań CRON w Codeigniter 3.0+ pojawia się poniższy błąd:
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
Powodem jest brak ustawionej w skrypcie strefy czasowej.
Wystarczy dodać do pliku:
config.php
linię
date_default_timezone_set('Europe/Warsaw');
W wersji CI 3.1 e-mail wysłany z załącznikiem jest błędnie kodowany i dociera do adresata z pustym załącznikiem mimo, że wiadomość zajmuje tyle miejsca jakby zawierała załącznik.
WARNING! This attachment is suspicious because its type doesn't match the type declared in the message. If you do not trust the sender, you shouldn't open it in the browser because it may contain malicious contents. Expected: application/pdf (.pdf); found: application/x-empty
Zobacz całość
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 reload
$config['encryption_key'] = "YOUR KEY";
$this->load->library('encrypt');
$msg = 'My secret message';
$key = 'super-secret-key';
$encrypted_string = $this->encrypt->encode($msg, $key);
$encrypted = 'APANtByIGI1BpVXZTJgcsAG8GZl8pdwwa84';
$key = 'super-secret-key';
$encrypted_string = $this->encrypt->decode($encrypted, $key);
Jeśli temat maila ma ponad 75 znaków, wysypuje się kodowanie.
http://stackoverflow.com/questions/8350865/malformed-email-subject-header-when-subject-75-chars-using-codeigniter-email-l
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/
Create a file (e.g. cron.php) in the same place as your index.php and system folder. Here is its code:
Zobacz całość
https://github.com/EllisLab/CodeIgniter/wiki/Language-Translation
https://github.com/codeigniter-polska/polish-language
Utworz folder o nazwie polish w katalogu application/language wgraj do niego wszystkie pliki z repozytorium.
W pliku konfiguracji application/config/config.php ustaw domyślny język na polski:
$config['language'] = 'polish';
http://php.net/manual/en/function.number-format.php #PHP
string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
http://phpjs.org/functions/number_format/ #Java Script
function number_format(number, decimals, dec_point, thousands_sep) { number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point, s = '', toFixedFix = function(n, prec) { var k = Math.pow(10, prec); return '' + Math.round(n * k) / k; }; // Fix for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); } if ((s[1] || '').length < prec) { s[1] = s[1] || ''; s[1] += new Array(prec - s[1].length + 1).join('0'); } return s.join(dec); } number_format(1234.56);
http://ellislab.com/codeigniter%20/user-guide/helpers/download_helper.html
Loading this Helper
This helper is loaded using the following code:
$this->load->helper('download');
The following functions are available:
force_download(filename‚, ‚data‚)
Generates server headers which force data to be downloaded to your desktop. Useful with file downloads. The first parameter is the name you want the downloaded file to be named, the second parameter is the file data. Example:
$data = 'Here is some text!'; $name = 'mytext.txt'; force_download($name, $data);
If you want to download an existing file from your server you’ll need to read the file into a string:
$data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents $name = 'myphoto.jpg'; force_download($name, $data);