2016-10-10 15:24:25 +02:00

43 lines
1.4 KiB
PHP
Executable File

<?php
class Profil extends ObjectModel {
public $id;
public $id_profil;
public $title;
public $description;
public static $definition = array(
'table' => 'diag_profil',
'primary' => 'id_profil',
'multilang' => true,
'fields' => array(
'id_profil' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isString'),
'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isString'),
),
);
public function getInfosWithValues($type = 'product', $id_lang = 1){
if ($type == 'product'){
$sqlProducts = Db::getInstance()->executeS('
SELECT p.`id_product` as id, pl.`name` as content
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'diag_profil_product` pp ON (p.`id_product` = pp.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`)
WHERE pp.`id_profil`='.(int)$this->id_profil.' AND pl.`id_lang`='.(int)$id_lang);
return $sqlProducts;
}
}
public static function getProfils($id_lang){
$profils = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT pl.`title`, p.*
FROM '._DB_PREFIX_.'diag_profil p
LEFT JOIN '._DB_PREFIX_.'diag_profil_lang pl on (pl.`id_profil` = p.`id_profil`)
WHERE pl.`id_lang` = '.(int)$id_lang.'
');
return $profils;
}
}