CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and id_value=3651 ORDER BY quantity DESC LIMIT 1' at line 1. The SQL statement executed was: SELECT price FROM `tbl_product_attribute` `t` WHERE id_product=10578 AND quantity<= and id_value=3651 ORDER BY quantity DESC LIMIT 1

/var/www/html/www.casatorres.com/private/yii-1.1.13.e9e4a0/framework/db/CDbCommand.php(541)

529         {
530             if($this->_connection->enableProfiling)
531                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
532 
533             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
534             $message=$e->getMessage();
535             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
536                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
537 
538             if(YII_DEBUG)
539                 $message.='. The SQL statement executed was: '.$this->getText().$par;
540 
541             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
542                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
543         }
544     }
545 
546     /**
547      * Builds a SQL SELECT statement from the given query specification.
548      * @param array $query the query specification in name-value pairs. The following
549      * query options are supported: {@link select}, {@link distinct}, {@link from},
550      * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},
551      * {@link limit}, {@link offset} and {@link union}.
552      * @return string the SQL statement
553      * @since 1.1.6

Stack Trace

#3
+
 /var/www/html/www.casatorres.com/webspace/protected/models/ProductAttribute.php(128): CActiveRecord->find(array("select" => "price", "condition" => "id_product=10578 AND quantity<= and id_value=3651", "order" => "quantity DESC"))
123         if(!empty($max)) return number_format($max->price,2,',','.');
124         return number_format($price,2,',','.');
125     }
126     
127     public static function getPrice($idprod,$q,$value){
128         $price=ProductAttribute::model()->find(array('select'=>'price','condition'=>"id_product=$idprod AND quantity<=$q and id_value=$value",'order'=>'quantity DESC'));
129         if(!$price) return SpecificPrice::getPrice($idprod,$q);
130         else return $price['price'];
131     }
132         
133     public static function getListAttributes($id){
#4
+
 /var/www/html/www.casatorres.com/webspace/protected/views/quefer/_itemAccessory.php(19): ProductAttribute::getPrice("10578", null, "3651")
14         </a>
15     
16     </p>
17     <p class="reference-item">REF: <?php echo str_replace("0000", "0", $model->product->reference); ?></p>
18     <p class="quantity-price">
19     <?php $price = ProductAttribute::getPrice($model->id_product_2,$model->quantity,$model->id_value); ?>
20     <span class="product-item-price">
21     <span class="product_<?php echo $model->id_product_2 ?>" id="price_<?php echo $model->id_accessory ?>"><?php echo number_format($price,2,",","."); ?></span>€
22     </span>
23     x 
24     <input maxlength="3" type="text" class="quantity-input quantity_<?php echo $model->id_product_2 ?>" id="quantity_<?php echo $model->id_accessory; ?>" onchange="newPrice(<?php echo $model->id_product_2.",this,".$model->id_value?>,1,1)" value="<?php echo $model->quantity; ?>"/>
#8
+
 /var/www/html/www.casatorres.com/webspace/protected/views/quefer/productDetall.php(247): CController->renderPartial("_itemAccessory", array("model" => Accessory))
242                     <div id="tbl-accessories">
243                     <?php foreach($comb as $c): ?>
244                         <?php if($c->product->active == 1): ?>
245                         <div class="item-row">
246                         <?php if($c->val_lang):?>
247                         <?php $this->renderPartial('_itemAccessory',array('model'=>$c)); ?>
248                         <?php else: ?>
249                             <?php $this->renderPartial('_itemProduct',array('model'=>$c)); ?>
250                         <?php endif; ?>
251                         </div>
252                         <?php endif; ?>
2024-03-28 11:04:16 Apache Yii Framework/1.1.13