comparison msitegen.inc.php @ 1093:7bfa5a38b6ca

Move function.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 26 Jan 2017 13:56:34 +0200
parents 7da8bde9b7be
children c9c73d2c4702
comparison
equal deleted inserted replaced
1092:95b74632cfe2 1093:7bfa5a38b6ca
545 } 545 }
546 return $dbh; 546 return $dbh;
547 } 547 }
548 548
549 549
550 function stDBGetSQLParam($dbh, $type, $value)
551 {
552 switch ($type)
553 {
554 case "d": return intval($value);
555 case "s": return $dbh->quote($value);
556 case "b": return intval($value) ? 1 : 0;
557 case "D": return intval(stGetRequestItem($value));
558 case "S": return $dbh->quote(stGetRequestItem($value));
559 case "Q": return $dbh->quote(stGetRequestItem($value));
560 case "B": return intval(stGetRequestItem($value)) ? 1 : 0;
561 }
562 }
563
564
565 function stConnectSQLDB() 550 function stConnectSQLDB()
566 { 551 {
567 global $db; 552 global $db;
568 try { 553 try {
569 $db = new PDO(stGetSetting("sqlDB"), 554 $db = new PDO(stGetSetting("sqlDB"),
575 stLogError("Could not connect to SQL database: ".$e->getMessage()."."); 560 stLogError("Could not connect to SQL database: ".$e->getMessage().".");
576 return FALSE; 561 return FALSE;
577 } 562 }
578 $db = stConnectSQLDBSpec(stGetSetting("sqlDB")); 563 $db = stConnectSQLDBSpec(stGetSetting("sqlDB"));
579 return ($db !== false); 564 return ($db !== false);
565 }
566
567
568 function stDBGetSQLParam($dbh, $type, $value)
569 {
570 switch ($type)
571 {
572 case "d": return intval($value);
573 case "s": return $dbh->quote($value);
574 case "b": return intval($value) ? 1 : 0;
575
576 case "D": return intval(stGetRequestItem($value));
577 case "S": return $dbh->quote(stGetRequestItem($value));
578 case "Q": return $dbh->quote(stGetRequestItem($value));
579 case "B": return intval(stGetRequestItem($value)) ? 1 : 0;
580 }
580 } 581 }
581 582
582 583
583 function stDBPrepareSQLUpdate($dbh, $table, $cond, $pairs) 584 function stDBPrepareSQLUpdate($dbh, $table, $cond, $pairs)
584 { 585 {