我正在与 Propel 和 Smarty 合作。我有一个servicios.php
文件,它只包含:
include('private/autoload.php');
// Servicios Todos
$servicios = ServicioQuery::Create()->orderByTitulo(Criteria::ASC)->find()->toArray();
$smarty->assign('servicios',$servicios);
// Servicio a mostrar
$servQry = ServicioQuery::Create();
if($url->getParam(3) == '') {
$servicio = $servQry->findOneByIdservicio(1);
}else{
$servicio = $servQry->findOneBySlug($url->getParam(3));
}
// Error Line ?
$servicio = $servicio->toArray();
$smarty->assign('servicio',$servicio);
$smarty->display('templates/servicio.tpl');
该文件servicio.tpl
包含:
<html>
<head>
{include file="html_head.tpl"}
</head>
<body>
....
<h2>{$servicio.Titulo}</h2>
<div class="span3">
<img class="borderFoto" src="assets/img/servicios/{$servicio.Slug}.jpg" alt="{$servicio.Slug}.jpg" />
</div>
<div class="span7">
{$servicio.Descripcion}
</div>
</body>
</html>
在html_head.tpl
:
<title>Pilar Medicina Estética</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
所以,问题是,Css 样式不加载。使用 Firebug 显示,不是打印 Css 代码,而是打印:
致命错误:在第15行的/media/Datos/www/PilarMedicinaEstetica/owner/servicios.php中的非对象上调用成员函数 toArray()
但是,该错误很少见,因为数据显示正确并且var_dump
不$servicio
标记错误:
array(7) { ["Idservicio"]=> int(1) ["Idsitio"]=> int(1) ["Titulo"]=> string(15) "Servicio demo 1" ["Description"]=> string(979) "Nulla commodo commodo iaculis...eget pellentesque nunc nisi ac sem。" ["Slug"]=> string(17) "servicio_demo_uno" ["Shares"]=> int(1) ["Activo"]=> bool(true) }
在 index.php 中,执行相同的步骤,然后工作。为什么这里没有?有任何想法吗 ?。