English 中文(简体)
CI的就业数据库产出
原标题:Empty database output in CI

I m 建造一个简单的仪器,并试图测试非银的成果产出。 但不幸的是,所有天花都是一阵亡。 The controller Code excerpt:

$data[ query ] = $this->db->query( SELECT role_id, role_privilege FROM role );
$this->load->view( welcome_message , $data);

观点守则摘录:

<?php
        echo count($query->result_array())."<br/>";
        foreach ($query->result() as $row){
            echo $row->role_id .  <br/> ;
            echo $row->role_privilege .  <br/> ;
        }
        echo  Total result  .$query->num_rows();
    ?>

我的下一步是:

0
Total result

一条指挥线的争.有2个连续产出。 谁能指出什么是失踪?

EDITED:
This issue is also discussed here .

EDITED:
Maybe some platform specific stuff (I really doubt that)? I m running LAMP (php 5.3.2, mysql 5.1.37, apache 2.2.15).

EDITED:
This prints out a "Array ( )" string. My DB is 100% filled. I can say that for sure, because I did

INSERT INTO role(role_privilege) VALUES ( ROLE_MODERATOR );
INSERT INTO role(role_privilege) VALUES ( ROLE_USER );

然后通过指挥线检查。

EDITED:
After I put this into my controller:

echo $this->db->last_query(); exit;

我获得下一个产出:

SELECT role_id, role_privilege FROM role

而这正是我所需要的。 不幸的是,成果是 array块。

最佳回答

这里的问题基本上不是 CI的问题,但奇怪的是, CI无法追踪这一错误。 下面是:

在安装Sphp I haven t specified-with-mysql-socket para amount时,它像Sphp一样,试图使用一种/tmp/mysql.sock(default one),这在我看来没有具体指明。 因此, CI试图对不存在的袖珍进行约束。 变幻灯片在A.K.ini的工厂解决问题。

问题回答

如果你不再犯错误,那么像你这样就能够适当打造。 我认为,这也意味着表格存在。 我知道你说,你听从指挥线的问话,但你是否相信你能够查阅同样的数据集/服务器/表格? 没有任何 version版或东西? 如同在角色表上有记录。 Sorry, Just grasping at raws as You Code look right.

如何做

SELECT * FROM role

之后

print_r($query->result_array()); 

您的看法? 这至少应显示一栏名称,以便你知道你再次获得正确数据。

ry问并报告任何细节,希望会提供一些方面。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签