Jump to content

SQL command won't exec in a module


Preyos

Recommended Posts

Hi all,

 

I work on a module, and I have to run sql command, but it won't work. Here is my code:

public function hookActionPaymentConfirmation($params)
{

$id_order = $params['id_order'];

$sqlSearchProd = 'SELECT id_product FROM ‘'._DB_PREFIX_.'order_detail’ WHERE id_order='.$id_order;
$id_product = Db::getInstance()->ExecuteS($sqlSearchProd);

	foreach ($id_product as $id_product)
	{
          $sqlSelectPric = 'SELECT price FROM ‘'._DB_PREFIX_.'product’ WHERE id_product='.$id_product;
          $price = Db::getInstance()->ExecuteS($sqlSelectPric);
           .....
        }

I update an order to "Accepted Payement". I activated the fulllog in mysql and a

cat mysql.log | grep id_product=

return nothing. So the foreach has not been executed...

 

Do you have any idea ?

 

Thank you in advance,

 

Alexandre

Link to comment
Share on other sites

Hi,

 

Thank you for your response :)

I don't know about the foreach, but, in doubt, here is my code:

$id_order = $params['id_order'];

$sqlSearchProd = 'SELECT id_product FROM ‘'._DB_PREFIX_.'order_detail’ WHERE id_order='.$id_order;
$id_prod = Db::getInstance()->ExecuteS($sqlSearchProd);
d($id_prod);

	foreach ($id_prod as $id_product)
	{
	$sqlSelectPric = 'SELECT price FROM ‘'._DB_PREFIX_.'product’ WHERE id_product='.$id_product;
	$price = Db::getInstance()->ExecuteS($sqlSelectPric);
        ...
        }

And the die return

END

The SQL command was not executed... I don't understand...

 

Alexandre

Edited by Preyos (see edit history)
Link to comment
Share on other sites

I recomend doing a p($sqlSearchProd)

Then you will see if something is missing, and you can also try to run it manually to check if there are any errors in code.

Also you don't seem to use the correct sign (`) around the ._DB_PREFIX_.'order_detail.

and in order_detail it's product_id and not id_product for some reason.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...