[英]mysql Simple Query + if
Seems like I'm not able to do a simple query. 似乎我无法执行简单的查询。
What I want to achieve is all the results that have 'best2' value '1' so the div will be attached to only those results. 我要实现的是所有具有“ best2”值“ 1”的结果,因此div将仅附加到那些结果。
Right now , the div 'badge-best2div' attaches to ALL the products. 现在,div'badge-best2div'附加到所有产品。
I don't know what I'm missing out. 我不知道我错过了什么。
<?php $show = true; ?>
<?php
$roman = Doctrine_Query::create()->from("Product")
->where("status = 1")
->andWhere("site_id = ? ", SITE_ID)
->andWhere("best2 = 1")
->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);
?>
<?php if ($product->getIsTop() && !isset($hide_badge_top)): $show = false;?>
<div class="badge-top"></div>
<?php endif; ?>
<?php if ($roman['best2']){
$show = false; ?>
<div class="badge-best2div"></div>
<?php } ?>
<?php if ($product->getIsBestBuy() && !isset($hide_badge_bestbuy) && $show): ?>
<div class="badge-bestbuy"></div>
<?php endif ; ?>
使用它
<?php if (($roman['best2'])==1){
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.