Search code examples
mysqlprestashopprestashop-1.6

How get a value from mysql in prestashop?


I want to get a value from a table like that:

SELECT id_image FROM `ps_image` WHERE id_product = 903 limit 1

How can i integrate this sql command in prestashop?


Solution

  • $product_id = '903';
    
    $query = Db:: getInstance()->getRow(
    'SELECT id_image FROM '._ DB_PREFIX_.'image WHERE id_product ='. $product_id
    );
    

    Use $query variable to get id of image.