I'm experiencing a strange problem while using CodeIgniter's Active Record class (looks like not only that, check update at bottom of question), and that happens only on some servers (belonging to the same provider). What happens is that the query is run only "partially", meaning that results are retrieved from mysql database, but any where
or join
or select
clause is ignored.
A simple example:
$this->db->select('title,intro');
$this->db->from('content');
$this->db->where('published','1');
$query = $this->db->get();
Doens't really work, because I get ALL fields and ALL results, even those with 'published' = '0'. The more complex the query, the worst the outcome.
Also, the same happens with any field datatype, so it's not a matter of using an INT and asking for a string. The above was just a sample, it happens with more "complex" queries like
$this->db->where('category','events');
$this->db->where('published','1');
$this->db->order_by('date','desc');
$this->db->limit($limit, $offset);
$query = $this->db->get('newsletter');
If I call $this->db->last_query()
it returns FALSE (bool); The only way I have to make it work is use standard mysql syntax, and do like
$sql = "SELECT title,intro FROM content WHERE published = '1'";
$query = $this->db->query($sql);
This works without any problem. Since I've a fair amount of experience in CodeIgniter I don't think it's me who's making errors in using the AR, since those query works locally and on other servers without problem.
I searched the net for similar problems but seems I'm out of luck or good google-fu skills today. I don't even know what could be going wrong, as the log files doens't show any error, adn I don't know what to look for in php.ini maybe. Anyway, here some INI values that might be involved, but I'm clueless:
allow_call_time_pass_reference Off Off
allow_url_fopen On On
always_populate_raw_post_data Off Off
auto_globals_jit On On
browscap no value no value
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors Off Off
enable_dl On On
error_reporting 2047 2047
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
log_errors On On
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
register_argc_argv Off Off
register_globals On On
register_long_arrays On On
safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value
Mysql:
Active Persistent Links 2
Active Links 2
Client API version 5.0.77
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
The virtual server runs PHP Version 5.1.6, on Apache/2.2.3 (CentOS).
What can I do to solve the problem?
Do I have to change some value in php.INI?
Or do I need to modify CI's ActiveRecord core?
Edit:
In such environment, it seems that also loading resources (helpers, libraries, modules) doesn't work, unless they're autoloaded. And the native redirect() doesn't work! I think they're all releted but I might be opening another question for that, in case I found out I'm wrong. What could cause such behaviour?