Hello There is a procedure

CREATE DEFINER=`123`@`localhost` PROCEDURE `coeficients_add`(IN `logistic` FLOAT, IN `vat` FLOAT, IN `manager` FLOAT, IN `curator` FLOAT, IN `admin` FLOAT, IN `status_add` INT, IN `sname` VARCHAR(50)) begin DECLARE I INT; DECLARE result INT; Declare done integer default 0; DECLARE curs CURSOR FOR select u.id FROM users AS u LEFT JOIN coefficients AS c ON u.id = c.user_id WHERE admin_coef IS NULL; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1; open curs; while done=0 DO FETCH curs INTO result; insert INTO `coefficients`(site_name,logistic, vat, manager_coef, curator_coef, admin_coef,user_id, status) values (sname,logistic,vat,manager,curator,admin,result,status_add); END WHILE; close curs; end 

In the sql, everything works as it should. I want to call through yi and pass parameters

  $products = Yii::app()->db->createCommand("CALL coeficients_add('logistic','vat','manager','curator','admin','status','site')") ->bindValue(':logistic', ($_POST['logistic'])) ->bindValue(':vat', ($_POST['vat'])) ->bindValue(':manager', ($_POST['manager'])) ->bindValue(':curator', ($_POST['curator'])) ->bindValue(':admin', ($_POST['admin'])) ->bindValue(':status',($_POST['status'])) ->bindValue(':site', quotemeta($site)) ->queryAll(); 

But the output gives an error:

 CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'logistic' in 'field list'. The SQL statement executed was: CALL coeficients_add(logistic,vat,manager,curator,admin,status,site) 

Which way to dig? Thank.

    1 answer 1

     Yii::app()->db->createCommand("CALL coeficients_add('logistic','vat','manager','curator','admin','status','site')") 

    Hmmm, what are you trying to bind the parameters to, if there is no placeholder in the request, neither positional nor named? It seems Yii transparently proxies request with parameters in PDO , but is not engaged in analysis of request itself.

    Probably you meant

     Yii::app()->db->createCommand("CALL coeficients_add(:logistic, :vat, :manager, :curator, :admin, :status, :site)") 
    • In some ways it helped, but now he does not see the main “mission” of the procedure - Column 'user_id' cannot be null. Although it is precisely the procedure that covers this field. Again, on pure sql everything works fine. I apologize for the wording, but for the first time I try the procedure call with yii, I guess what is wrong. - Roma Tulaydan
    • Thanks, what you need - Roma Tulaydan