本文整理汇总了PHP中DataBase::GetDbInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::GetDbInstance方法的具体用法?PHP DataBase::GetDbInstance怎么用?PHP DataBase::GetDbInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::GetDbInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DeleteWaluta
/**
* Delete waluta from database, given by symbol.
* @param string $symbol
*/
public static function DeleteWaluta($symbol)
{
$query = "DELETE FROM #S#waluty_kursy WHERE 1=1";
if ($symbol != null) {
$query .= " AND waluta=?";
$params[] = $symbol;
}
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, $params);
}
示例2: getList
public static function getList($enum_id)
{
$db = DataBase::GetDbInstance();
$query = "SELECT * FROM listy WHERE enum_id = ?";
$params = array((int) $enum_id);
$return = array();
$result = $db->ExecuteQueryWithParams($query, $params);
while ($row = $db->FetchArray($result)) {
$return[] = $row['value'];
}
return $return;
}
示例3: DeleteUnUsePhotos
/**
* Delete all unused photos, that are no longer published.
* @param int $offerId
* @param array $Ids
* @param mixed $investmentId
*/
public static function DeleteUnUsePhotos($offerId = false, $Ids = array(), $investmentId = false)
{
if (count($Ids) > 0 && $offerId) {
$params = array();
$params[] = (int) $offerId;
$params['not_ids'] = $Ids;
$filters = self::PrepareFilters($params);
$inBind = implode(',', array_fill(0, count($Ids), '?'));
//first delete from disk
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("SELECT id, filename FROM #S#offers_photos WHERE offers_id=? AND id NOT IN ({$inBind})", $filters);
while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
self::DeletePhotoFromDisk($row[0], $offerId, 0, $row[1]);
}
//now from database
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("DELETE FROM #S#offers_photos WHERE offers_id=? AND id NOT IN ({$inBind})", $filters);
} else {
self::DeletePhotoFromDisk(0, $offerId);
}
if (count($Ids) > 0 && $investmentId) {
$params = array();
$params[] = (int) $investmentId;
$params['not_ids'] = $Ids;
$filters = self::PrepareFilters($params);
$inBind = implode(',', array_fill(0, count($Ids), '?'));
//first delete from disk
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("SELECT id FROM #S#offers_photos WHERE investments_id=? AND id NOT IN ({$inBind})", $filters);
while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
self::DeletePhotoFromDisk($row[0], $offerId);
}
//now from database
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("DELETE FROM #S#offers_photos WHERE investments_id=? AND id NOT IN ({$inBind})", $filters);
} else {
self::DeletePhotoFromDisk(0, 0, $investmentId);
}
}
示例4: MaParametr
/**
*
* @param int $gid
* @return bool
*/
public function MaParametr($param)
{
if (is_numeric($param)) {
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("SELECT COUNT(GID) FROM #S#artykuly_parametry WHERE GID=? AND artykuly_GID=? AND IdJezyk=?", array((int) $param, (int) $this->_GID, (int) $this->_IdJezyk));
} else {
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("SELECT COUNT(GID) FROM #S#artykuly_parametry WHERE ParamNazwa=? AND artykuly_GID=? AND IdJezyk=?", array($param, (int) $this->_GID, (int) $this->_IdJezyk));
}
if ($result) {
$row = DataBase::GetDbInstance()->FetchArray($result);
return $row && $row[0] > 0;
} else {
return false;
}
}
示例5: GetOffers
/**
* Returns array of offers investment.
* @param int $investmentId
* @param int $lngId
* @return array
*/
public static function GetOffers($investmentId, $lngId = 1045)
{
$db = DataBase::GetDbInstance();
$params = array((int) $investmentId, (int) $lngId);
$query = "SELECT o.id FROM #S#offers o INNER JOIN #S#investments_buildings b ON o.investments_buildings_id=b.id WHERE b.investments_id=? AND o.id_lng=? ORDER BY o.id";
$result = $db->ExecuteQueryWithParams($query, $params);
$offers = array();
while ($row = $db->FetchArray($result)) {
$offers[] = Offers::getOffer($row[0], $lngId);
}
return $offers;
}
示例6: IndeksujGaleriePozycjeDlaGalerii
public static function IndeksujGaleriePozycjeDlaGalerii($galeria_gid)
{
$del_query = "DELETE a_gp FROM #S#artykuly_galeriepozycje AS a_gp INNER JOIN #S#galeriepozycje AS gp ON a_gp.galeriepozycje_GID=gp.GID WHERE gp.galerie_GID=?";
$del_result = DataBase::GetDbInstance()->ExecuteQueryWithParams($del_query, array((int) $galeria_gid));
$query = "SELECT GID, Tagi FROM #S#artykuly WHERE Tagi <> '' AND IdJezyk=1045";
$sub_query = "SELECT GID FROM #S#galeriepozycje WHERE Tagi <> '' AND Tagi LIKE ? AND IdJezyk=1045 AND galerie_GID=?";
$ins_query = "INSERT INTO #S#artykuly_galeriepozycje (artykuly_GID, galeriepozycje_GID) VALUES(?, ?);";
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, array());
while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
$tagi = explode(",", $row['Tagi']);
$unique_tags = array();
foreach ($tagi as $tag) {
if (!isset($unique_tags[$tag])) {
$sub_result = DataBase::GetDbInstance()->ExecuteQueryWithParams($sub_query, array('%' . $tag . '%', (int) $galeria_gid));
while ($sub_row = DataBase::GetDbInstance()->FetchArray($sub_result)) {
$ins_result = DataBase::GetDbInstance()->ExecuteQueryWithParams($ins_query, array($row['GID'], $sub_row['GID']));
}
$unique_tags[$tag] = true;
}
}
}
}
示例7: AddOffersToBuilding
/**
* Add offers from xml to given investment building.
* @param xmlnode $offersNode
* @param InvestmentBuilding $bulding
*/
public static function AddOffersToBuilding($offersNode, InvestmentBuilding $bulding)
{
if ($offersNode != null && $offersNode->children != null) {
foreach (@$offersNode->children() as $ofeNode) {
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("UPDATE #S#offers SET investments_buildings_id=? WHERE id=?", array($bulding->GetId(), (int) $ofeNode['wartosc']));
}
}
}
示例8: GetJezyki
/**
* Returns list of language text ready to serialize.
* @return array
*/
public static function GetJezyki()
{
$result = DataBase::GetDbInstance()->ExecuteQuery("SELECT * FROM #S#jezyki");
$arr = array();
while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
$jt = self::BuildJezyk($row);
//$arr[count($arr)] = $jt;
if (!array_key_exists($jt->GetKlucz(), $arr)) {
$arr[$jt->GetKlucz()] = array();
}
$arr[$jt->GetKlucz()][$jt->GetIdJezyk()] = $jt->GetWartosc();
}
return $arr;
}
示例9: LoadProperties
private function LoadProperties()
{
//dynamic properties
if ($this->dataLoaded) {
return;
}
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("SELECT p.name, op.value, op.set FROM #S#investments_properties AS op INNER JOIN #S#properties AS p ON p.id = op.properties_id WHERE op.investments_id=? AND op.investments_id_lng=?", array((int) $this->GetId(), (int) $this->GetIdLng()));
while ($row2 = DataBase::GetDbInstance()->FetchArray($result)) {
if ($row2['set'] == 1) {
$set = null;
if (array_key_exists($row2['name'], $this->data)) {
$set = $this->data[$row2['name']];
}
$set[count($set)] = $row2['value'];
$this->data[$row2['name']] = $set;
} else {
$this->data[$row2['name']] = $row2['value'];
}
}
$this->dataLoaded = true;
}
示例10: SavePropertyValueForInv
/**
* Save value of given property in given investment.
* @param Property $prop
* @param Investment $inv
* @param string $value
* @param bool $isNew
* @param array $dbValuesList
*/
public static function SavePropertyValueForInv(Property $prop, Investment $inv, $value, $isNew, $dbValuesList)
{
is_numeric($inv->GetId()) ? $get_id = (int) $inv->GetId() : ($get_id = $inv->GetId());
is_numeric($inv->GetIdLng()) ? $get_lng_id = (int) $inv->GetIdLng() : ($get_lng_id = $inv->GetIdLng());
is_numeric($prop->GetID()) ? $get_prop_id = (int) $prop->GetID() : ($get_prop_id = $prop->GetID());
if ($isNew) {
//if offer is new, then directly make insert, instead of checking if record exist in db
if (is_array($value)) {
foreach ($value as $val) {
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("INSERT INTO #S#investments_properties (investments_id, investments_id_lng, properties_id, value, `set`, hash) VALUES(?, ?, ?, ?, true, ?)", array($get_id, $get_lng_id, $get_prop_id, $val, md5($val)));
}
} else {
$query = "INSERT INTO #S#investments_properties (investments_id, investments_id_lng, properties_id, value, `set`, hash) VALUES(?, ?, ?, ?, false, ?)";
$params = array($get_id, $get_lng_id, $get_prop_id, $value, md5($value));
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, $params);
}
} else {
//if offer exist, check if value exist in db
if (is_array($value)) {
$dbvalues = array();
if (array_key_exists($prop->GetID(), $dbValuesList)) {
foreach ($dbValuesList[$prop->GetID()] as $dbval) {
if (in_array($dbval["value"], $value)) {
$dbvalues[count($dbvalues)] = $dbval["value"];
} else {
//delete from database
$result2 = DataBase::GetDbInstance()->ExecuteQueryWithParams("DELETE FROM #S#investments_properties WHERE id=?", array((int) $dbval['id']));
}
}
}
foreach ($value as $val) {
if (!in_array($val, $dbvalues)) {
//insert to database
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams("INSERT INTO #S#investments_properties (investments_id, investments_id_lng, properties_id, value, `set`, hash) VALUES(?, ?, ?, ?, true, ?)", array($get_id, $get_lng_id, $get_prop_id, $val, md5($val)));
}
}
} else {
$row = null;
if (array_key_exists($prop->GetID(), $dbValuesList)) {
$row = $dbValuesList[$prop->GetID()][0];
}
$query = "";
if ($row == null) {
$query = "INSERT INTO #S#investments_properties (investments_id, investments_id_lng, properties_id, value, `set`, hash) VALUES(?, ?, ?, ?, false, ?)";
$params = array($get_id, $get_lng_id, $get_prop_id, $value, md5($value));
} else {
if ($row['value'] != $value) {
$query = "UPDATE #S#investments_properties SET value=?, hash=? WHERE investments_id=? AND investments_id_lng=? AND properties_id=?";
$params = array($value, md5($value), (int) $get_id, (int) $get_lng_id, (int) $get_prop_id);
}
}
if ($query != "") {
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, $params);
}
}
}
}
示例11: PobierzMiejscaMenu
/**
* Return list of MiejscaMenu objects selected with given filters.
* @param array $ht
* @param int $idLng
* @return Miejsce[]
*/
public static function PobierzMiejscaMenu($ht, $idLng = 1045)
{
$query = "SELECT m.* FROM #S#miejsca AS m WHERE m.Rodzaj=" . Miejsca::MIEJSCE_RODZAJ_MENU . " AND IdJezyk=? ";
if ($ht != null) {
foreach ($ht as $key => $value) {
switch ($key) {
case "GID":
$query .= " AND m.GID=?";
break;
case "IdRodzic":
if ($value == "null") {
$query .= " AND m.Parent_GID IS NULL";
} else {
$query .= " AND m.Parent_GID=?";
}
break;
case "GIDSerwis":
$query .= " AND m.serwisy_GID=?";
break;
case "Lp":
$query .= " AND m.Lp=?";
break;
case "Nazwa":
$query .= " AND m.NazwaGlowna LIKE ?";
break;
default:
$query .= " AND m.{$key}=?";
break;
}
}
}
$list = array();
$params = array_merge(array((int) $idLng), self::prepareFilters($ht));
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, $params);
while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
$list[count($list)] = self::BuildMiejsce($row);
}
return $list;
}
示例12: Params
/**
* Gets serwis params from database
* @param string $key
* @param object $defValue
* @return array[]
*/
public static function Params($key, $defValue = null)
{
if (self::$_Params == null) {
self::$_Params = array();
$db = DataBase::GetDbInstance();
$query = "SELECT key_name, value FROM #S#settings";
$result = $db->ExecuteQuery($query);
if ($result) {
while ($row = $db->FetchArray($result)) {
self::$_Params[$row['key_name']] = $row['value'];
}
}
}
if (array_key_exists($key, self::$_Params)) {
return self::$_Params[$key];
} else {
return $defValue;
}
}
示例13: DeleteArtykulParametry
/**
* Delete artykul parametrs from database, given by ARTYKUL GID.
* @param int $gidArtykul
* @param int $idLng
*/
public static function DeleteArtykulParametry($gidArtykul, $idLng = 0)
{
$query = "DELETE FROM #S#artykuly_parametry WHERE 1=1";
$params = array();
if ($gidArtykul > 0) {
$query .= " AND artykuly_GID=?";
$params[] = (int) $gidArtykul;
}
if ($idLng > 0) {
$query .= " AND IdJezyk=?";
$params[] = (int) $idLng;
}
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, $params);
}
示例14: DeleteDepartment
/**
* Delete department from database, given by ID.
* @param int $id
*/
public static function DeleteDepartment($id = 0)
{
$params = array();
$query = "DELETE FROM #S#departments WHERE 1=1 ";
if ($id > 0) {
$query .= " AND id=?";
$params[] = $id;
}
$result = DataBase::GetDbInstance()->ExecuteQueryWithParams($query, $params);
}
示例15: GetOpcje
/**
* Returns list of options ready to serialize.
* @return array
*/
public static function GetOpcje()
{
$result = DataBase::GetDbInstance()->ExecuteQuery("SELECT * FROM #S#opcje");
$arr = array();
while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
$arr[$row["klucz"]] = $row["wartosc"];
}
return $arr;
}