php/heslo/lib/funkce.inc.php
changeset 15 ad391f838b9d
parent 13 119744ae4179
     1.1 --- a/php/heslo/lib/funkce.inc.php	Sun May 10 01:13:12 2009 +0200
     1.2 +++ b/php/heslo/lib/funkce.inc.php	Fri May 29 15:12:02 2009 +0200
     1.3 @@ -100,6 +100,34 @@
     1.4  	return null;
     1.5  }
     1.6  
     1.7 +function sqlDotaz($dotaz, $parametry = null) {
     1.8 +        global $db;
     1.9 +        try {
    1.10 +                $dotaz = $db->prepare($dotaz);
    1.11 +
    1.12 +                if ($parametry != null) {
    1.13 +                        for($i = 0; $i < count($parametry); $i++) {
    1.14 +                                $dotaz->bindParam($i+1, $parametry[$i]);
    1.15 +                        }
    1.16 +                }
    1.17 +
    1.18 +                $dotaz->execute();
    1.19 +                $r = $dotaz->fetchAll();
    1.20 +
    1.21 +                return $r;
    1.22 +        } catch (PDOException $e) {
    1.23 +                logujChybu("sqlDotaz($dotaz)");
    1.24 +        }
    1.25 +}
    1.26 +
    1.27 +function echoClanek($id, $nadpis = 'h2') {
    1.28 +    $r = sqlDotaz("SELECT * FROM clanek WHERE id = ?", $id);
    1.29 +    foreach ($r as $x) {
    1.30 +	htmlZnacka($nadpis, $x['nadpis']);
    1.31 +	echo($x['text']);		
    1.32 +    }
    1.33 +}
    1.34 +
    1.35  function getMicrotime(){
    1.36     list($usec, $sec) = explode(" ",microtime());
    1.37     return ((float)$usec + (float)$sec);