geomen 发表于 2013-9-4 18:45:13

cli怎样获取数据库数据

请问下,我在浏览器上访问能访问下从数据库上获取的数据,,

在命令行下怎么却获取不到,
是不是在命令模式下获取数据库数据跟普通的模式下获取数据方式不一样?
要怎么办呢?

Hex 发表于 2013-9-4 20:04:09

贴代码

geomen 发表于 2013-9-5 09:24:41

本帖最后由 geomen 于 2013-9-5 09:29 编辑

比如我根据手册上写的
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {
      public function index()
      {
      $query = $this->db->get('design');
      foreach($query->result() as $row){
            echo $row->name;
      }
                //$this->load->view('welcome_message');
      }
    public function message($to="world"){
      $query = $this->db->get('design');
      echo $query->num_fields().PHP_EOL;
      echo "hello {$to}!".PHP_EOL;
    }
}

在网页上,第一个和第二个都能显示,
http://localhost/capaerp/capa/ci.php/welcome/message j显示:42 hello world!
http://codeigniter.org.cn/forums/data/attachment/album/201309/05/092514vl16916esbuqbzsu.png
http://localhost/capaerp/capa/ci.php/welcome/index 显示:
测试8测试六tes5测试1test4test6123测试1test2test12324d123123438888323tettt3232yyyyyyyu32333hhhffff一下子123123444444444444555

然后,我用命令行:
php ci.php welcome/message
http://codeigniter.org.cn/forums/data/attachment/album/201309/05/092515ptusr2rt4t6dht1d.png
就只显示 hello world 了

geomen 发表于 2013-9-5 10:02:47

Hex 发表于 2013-9-4 20:04 static/image/common/back.gif
贴代码

我帖代码了,麻烦你看下!!

Hex 发表于 2013-9-5 10:20:41

geomen 发表于 2013-9-5 10:02 static/image/common/back.gif
我帖代码了,麻烦你看下!!

参考 http://codeigniter.org.cn/user_guide/general/cli.html
你应该这样 php ci.php welcome message

geomen 发表于 2013-9-5 10:40:36

Hex 发表于 2013-9-5 10:20 static/image/common/back.gif
参考 http://codeigniter.org.cn/user_guide/general/cli.html
你应该这样 php ci.php welcome message



呃!还是跟welcome/message一样的结果!

Hex 发表于 2013-9-5 12:07:28

geomen 发表于 2013-9-5 10:40 static/image/common/back.gif
呃!还是跟welcome/message一样的结果!

从配置什么的来说,都是一样的。
你看看有什么报错吗?我觉得是有报错但是给屏蔽了。

页: [1]
查看完整版本: cli怎样获取数据库数据