codeigniter活动记录(而不是只)有些服务器上特有的问题 [英] Codeigniter Active Record (and not only that) peculiar problem on some server

查看:384
本文介绍了codeigniter活动记录(而不是只)有些服务器上特有的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的问题,而使用codeIgniter的Active Record类(看起来不仅如此,检查更新在问题的底部),这仅发生在一些服务器(属于到同一服务提供商)。什么情况是,查询运行只是部分,这意味着结果是从MySQL数据库中检索,但任何其中,加入选择子句将被忽略。

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.

一个简单的例子:

$this->db->select('title,intro');
$this->db->from('content');
$this->db->where('published','1');
$query = $this->db->get();

好好尝试一下真正的工作,因为我得到的所有领域和所有的结果,即使是那些'发表'='0'。更复杂的查询,最坏的结果。

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.

另外,同样发生在任何领域的数据类型,所以它不是用INT和要求一个字符串的问题。以上只是一个样本,它更复杂的查询偏偏喜欢

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');

如果我称之为 $这个 - > DB-> last_query()返回FALSE(布尔);我要使它发挥作用的唯一方式是使用标准的MySQL语法,并做到像

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);

这工作没有任何问题。 因为我在codeIgniter的经验,相当数量的,我不认为这是我的谁在使用AR犯错误,因为这些查询工作在本地和其他服务器没有问题。

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.

我搜索网的类似问题,但看来我的运气还是不错的谷歌福技能今天。我甚至不知道有什么可以去错了,因为日志文件好好尝试一下显示任何错误,ADN我不知道要查找在php.ini什么,也许。总之,这里可能涉及一些INI值,但我无言以对:

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的:

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

在虚拟服务器上运行PHP版本5.1.6,在Apache / 2.2.3(CentOS的)。

The virtual server runs PHP Version 5.1.6, on Apache/2.2.3 (CentOS).

我能做些什么来解决这个问题?
我一定要改变在php.ini一定的价值?
或者我需要修改CI的ActiveRecord的核心是什么?

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?

在这样的环境中,似乎还加载资源(佣工,库模块)不工作,除非他们自动加载。而本机的重定向()不工作!我觉得他们都releted,但我可能会打开另外一个问题要问的是,如果我发现我错了。这是什么原因这样的行为?

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?

推荐答案

一个简单的事情值得尝试的却是:

One simple thing worth trying instead is:

$this->db->where('published', 1);

我记得codeigniter要么incluse排除'1左右,在实际查询取决于该值是一个整数,浮动或字符串。

I recall Codeigniter to either incluse of exclude '' around 1 in the actual query depending on if the value is an integer, float or a string.

你使用的$最新版本的C $ cIgniter?

Do you use the latest version of CodeIgniter?

这篇关于codeigniter活动记录(而不是只)有些服务器上特有的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆