update
This commit is contained in:
64
core/model/LinkLangDAL.class.php
Normal file
64
core/model/LinkLangDAL.class.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Klasa obsługi tablicy mf_product
|
||||
*
|
||||
*/
|
||||
class LinkLangDAL {
|
||||
|
||||
public static function Add($id) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
|
||||
$sql = "INSERT INTO mf_link_lang (id_lang_pl) VALUES ($id)";
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
}
|
||||
|
||||
public static function Update($idPl, $idLang, $lang) {
|
||||
$db = Registry::Get('db');
|
||||
$sql = 'SELECT id_lang_pl FROM mf_link_lang WHERE 1=1 ' .
|
||||
" AND id_lang_" . $lang . " = $idLang" .
|
||||
" GROUP BY id_lang_pl";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->execute($sql);
|
||||
if ($arrayLangId = $stmt->FetchArray()) {
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = "UPDATE mf_link_lang SET id_lang_$lang = $idLang WHERE id_lang_pl = $idPl";
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
} else {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
|
||||
$sql = "INSERT INTO mf_link_lang (id_lang_pl, id_lang_$lang) VALUES ($idPl, $idLang)";
|
||||
|
||||
$stmt = $db->prepare($sql)->execute();
|
||||
return $stmt->GetInsertionId();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetSelected($idStructure, $lang) {
|
||||
|
||||
$db = Registry::Get('db');
|
||||
$sql = 'SELECT id_lang_pl FROM mf_link_lang WHERE 1=1 ' .
|
||||
" AND id_lang_" . $lang . " = $idStructure" .
|
||||
" GROUP BY id_lang_pl";
|
||||
//Utils::ArrayDisplay($sql);
|
||||
$stmt = $db->execute($sql);
|
||||
if ($arrayLangId = $stmt->FetchArray()) {
|
||||
$idLangPl = $arrayLangId['id_lang_pl'];
|
||||
return $idLangPl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user