|
PHP复制代码
$this->load->database();
$this->db->select('title','keywords');
//$this->db->select('keywords');
$this->db->from('site');
$query = $this->db->get();
$data['query'] = $query;
$this->load->view('result',$data);
复制代码
PHP复制代码
<?php foreach ($query->result() as $row):?>
<p>
<span style="color:#0f0"><?php echo $row->title?></span>
<span style="color:#0f0"><?php echo $row->keywords?></span>
</p>
<?php endforeach;?>
复制代码
如果使用
PHP复制代码 $this->db->select('title','keywords'); 复制代码
在view中访问除第一个属性外就会说
PHP复制代码
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$keywords
Filename: views/result.php
Line Number: 11
复制代码
如果用:
PHP复制代码
$this->db->select('title');
$this->db->select('keywords');
复制代码
写2条语句就能访问到
郁闷,这是啥原因,
我看电子书教程里一次查好几个:
PHP复制代码
$this->db->select('url','name','clientid','people.surname AS client');
复制代码
我的版本是1.7.2 xampp集成环境 5.3的php |
|