codeigniter-2

Update query increment field plus 1 codeigniter

落爺英雄遲暮 提交于 2019-11-29 08:21:44
I got a problem when trying to increment by 1 on given field in my db. I tried with and without active records. My functions look like this (in my model) function _set_reads($id){ $this->db->set('reads', 'reads+1', FALSE) $this->db->where('id', $id); $this->db->update('article'); } and function _set_reads($id){ $sql = 'update article set reads=reads+1 where id=?'; $this->db->query($sql, array($id)); } I get the same error in both cases and it's the following error message: Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

CodeIgniter compatibility with PHP version?

雨燕双飞 提交于 2019-11-29 07:48:00
I am using CodeIgniter 2.2.6 with PHP 5.5 and it works fine. Now I want to upgrade PHP to version 5.6.6 my question is, is CodeIgniter compatible with PHP 5.6.6? I can't upgrade CodeIgniter to a new version because I have many models based on Version 2.2.6. Codeigniter 2.2x IS COMPATIBLE with PHP7.1+. You only need to remember: Models/classes and so on are case-sensitive and have to start from capital letter The same with names of files in application folder There are problems with mysql (very old, not used now driver) so you have to use mysqli driver (but it is already implemented in CI2,

CodeIgniter Validation: possible to validate GET query strings?

元气小坏坏 提交于 2019-11-29 07:32:31
The form validation library seems to only work on POST. I need to use query strings and would like to use CI to validate the passed values. Is there a way to do this? The current Codeigniter 3.0 development branch provides an option to insert your own variable instead of $_POST. So you could start using 3.0. Alternatively, the only way in CI2.1 is to do $_POST=$_GET before you run the validation. See this page for the CodeIgniter 3 solution:- http://www.codeigniter.com/userguide3/libraries/form_validation.html#validating-an-array-other-than-post For CodeIgniter 2 you can do $_POST = $_GET;

CodeIgniter use CSRF protection only in some pages

我们两清 提交于 2019-11-29 07:22:18
What I want to do is to protect some sensitive forms from CSRF attack in codeigniter but not all pages. To protect from CSRF if I set it in config.php it applies for all pages. is there any way to do that only for some pages by setting in controller? $config['csrf_protection'] = TRUE; Now the CI3 have this feature, we can exclude the URIs in the config http://www.codeigniter.com/userguide3/libraries/security.html?highlight=csrf#cross-site-request-forgery-csrf $config['csrf_exclude_uris'] = array('api/person/add'); $config['csrf_exclude_uris'] = array( 'api/record/[0-9]+', 'api/title/[a-z]+' );

Autoload language codeigniter

99封情书 提交于 2019-11-29 02:26:18
making a multi-language site with codeginiter. I have created two folders. One for french language files and one for english. When I go to autoload the languages (English and French) as such ($autoload['language'] = array('en', 'fr');) I get an error "Unable to load the requested language file: language/english/fr_lang.php" How can I get it to look in the proper folder? Thanks $config['language'] is the default folder used for loading language files, which is why your fr_lang.php is loaded from there. Either change the value of: $config['language'] when needed, like: $this->config->set_item(

Where to place global functions in codeigniter

六眼飞鱼酱① 提交于 2019-11-28 20:24:40
I have created a few utility functions like one h() that acts as echo htmlentities($var) . I want theses functions to be available everywhere . so where do i put it. As @david barker said, you might use an helper. Create a file named, for example, "site_helper", that contains all the functions. be aware you need to check if the function already exists, though, or you'll get an "function already declared" error. So, something like: file site_helper.php (in application/helpers/ ) if(!function_exists('h')) { function h($value) { return htmlentities($value); } } if(!functin_exists('other_function'

How do I run CodeIgniter migrations?

空扰寡人 提交于 2019-11-28 16:58:58
I know how to create them via http://codeigniter.com/user_guide/libraries/migration.html But once I've created my migration files, how do I run them? I am not sure this is the right way to do it, But It works for me. I created a controller named migrate (controllers/migrate.php) . <?php defined("BASEPATH") or exit("No direct script access allowed"); class Migrate extends CI_Controller{ public function index($version){ $this->load->library("migration"); if(!$this->migration->version($version)){ show_error($this->migration->error_string()); } } } Then from browser I will call this url to execute

Processing large amounts of data in PHP without a browser timeout

半腔热情 提交于 2019-11-28 16:54:19
问题 I have array of mobile numbers, around 50,000. I'm trying to process and send bulk SMS to these numbers using third-party API, but the browser will freeze for some minutes. I'm looking for a better option. Processing of the data involves checking mobile number type (e.g CDMA), assigning unique ids to all the numbers for further referencing, check for network/country unique charges, etc. I thought of queuing the data in the database and using cron to send about 5k by batch every minute, but

fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known

女生的网名这么多〃 提交于 2019-11-28 14:19:10
I am failing to send form contents to email. I am getting the following error: : Warning Message: fsockopen(): php_network_getaddresses: getaddrinfo failed:Name or service not known Filename: libraries/Email.php Line Number: 1986 Severity: Warning Message: fsockopen(): unable to connect to ssl://smtp.123mailsetup.com:25 (php_network_getaddresses: getaddrinfo failed: Name or service not known) Filename: libraries/Email.php Line Number: 1986 My line 1986 is $this->smtp_timeout); Part of the code in my controller $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'smtp.xxxx.com', 'smtp_port' =

CodeIgniter - Simple base_url question

限于喜欢 提交于 2019-11-28 13:13:00
I'm a bit confused here. I have a simple controller which loads a view. The view contains a form and links some CSS files. I don't really want to do ../../css/global.css in my link tag. I want to use the base_url() method and then go /css/. I know a friend uses the following: <link href="{base_url}css/style.css" rel="stylesheet" type="text/css" /> However, I can't get that to work. He uses CodeIgniter 1.7 though, I'm using the latest (2.something) version. I'm new to CodeIgniter and I wanted to mess around with it, but I can't even link a simple CSS file :( My view is in /logic/views/index.php