【发布时间】:2014-04-30 08:47:57
【问题描述】:
我无法显示数据。
我的模型(app/Model/Product.php)
class Product extends AppModel {
public $name = 'Product';
}
我的控制器(app/Controller/ProductsController.php):
class ProductsController extends AppController {
public $helpers = array('Html','Form','Session');
public $components = array('Session');
public $name = 'Products';
public function ver($id = null) {
$this->Product->id_producto = $id;
debug($this->Product->id_producto); //Show id with value Ex. 12,34,...
$this->set('products', $this->Product->read());
}
}
我的观点(app/View/ver.ctp):
<?php debug($product['Product']['nombre']); ?> // Show 'null'
<h2><?php echo $product['Product']['nombre']?></h2></td></tr>
<strong>Descripción:</strong> <?php echo $product['Product']['descripcion']?> <br/>
<small>Fecha de registro: <?php echo $product['Product']['fecha_reg']?></small> <br/>
<small>Última modificación: <?php echo $product['Product']['Fecha_mod']?></small>
【问题讨论】:
-
查看book.cakephp.org/2.0/en/models/retrieving-your-data.html 和stackoverflow.com/questions/21819451/… 正如@nedstark 所说,您应该使用
find
标签: cakephp model controller