コード例 #1
0
ファイル: SPDO.php プロジェクト: able-to-include/email-client
 public static function singleton()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
ファイル: ModelBase.php プロジェクト: noxss/nx-framework
 public function __construct()
 {
     $this->db = SPDO::singleton();
     if ($this->db != false) {
         //$this->db->exec('SET CHARACTER SET UTF8');
     }
 }
コード例 #3
0
 /**
  * Crée et retourne l'objet SPDO
  *
  * @access public
  * @static
  * @param void
  * @return SPDO $instance
  */
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new SPDO();
     }
     return self::$instance;
 }
コード例 #4
0
 public function __construct()
 {
     /*
      * --------------------
      * Database Connection
      * --------------------
      */
     $this->db = SPDO::singleton();
     $this->_dateNow = date('Y-m-d G:i:s', time());
 }
コード例 #5
0
ファイル: SPDO.php プロジェクト: noxss/nx-framework
 public static function singleton()
 {
     if (self::$instance == null) {
         $config = Config::singleton();
         if ($config->get('dbname') != '' or $config->get('dbuser') != '') {
             self::$instance = new self();
         } else {
             return false;
         }
     }
     return self::$instance;
 }
コード例 #6
0
 function get_all_attendee_IDs()
 {
     $connect = SPDO::getInstance();
     $sth = $connect->prepare('SELECT `id_person` FROM `people` order by `id_person`');
     //$sth->bindParam(':login', $login);
     $sth->execute();
     $result = array();
     while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT)) {
         array_push($result, $row['id_person']);
     }
     return $result;
 }
コード例 #7
0
 public function updateOrder($sIdOrder, $aData)
 {
     $sReq = "UPDATE products_orders set id_transaction=:id_transaction, chekoutstatus=:status WHERE id_order=:id_order";
     $update = SPDO::getInstance()->prepare($sReq);
     $update->bindParam(':id_transaction', $aData['PAYMENTINFO_0_TRANSACTIONID']);
     $update->bindParam(':status', $aData['PAYMENTINFO_0_PAYMENTSTATUS']);
     $update->bindParam('id_order', $sIdOrder);
     try {
         $result = $update->execute();
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
 }
コード例 #8
0
 /**
  * Vérification du mot de passe saisit par l'utilisateur et celui stocké en base.
  *
  * @param string $req Requête qui recupére le password haché en base
  * @param string $sPasswordUser Password saisit par l'utilisateur
  * @return boolean true:password OK ; false:password KO
  **/
 public function verify_password_database($req, $sloginEnter, $sPasswordUser)
 {
     $stmt = SPDO::getInstance()->prepare($req);
     $stmt->bindvalue(':sloginEnter', $sloginEnter);
     $stmt->execute();
     $aPwd_hash = $stmt->fetchAll();
     if (!empty($aPwd_hash)) {
         $sPwd_hash = $aPwd_hash[0][0];
     } else {
         $sPwd_hash = null;
     }
     return $this->pwd_verify($sPasswordUser, $sPwd_hash);
 }
コード例 #9
0
ファイル: Accion.class.php プロジェクト: jlegrand88/sigpro
 static function find($idAccion)
 {
     $coneccion = SPDO::singleton();
     try {
         $consulta = $coneccion->query("SELECT * FROM accion WHERE id_accion = {$idAccion};");
         $resultado = $consulta->fetch(PDO::FETCH_ASSOC);
         return $resultado;
     } catch (PDOException $e) {
         echo "Se ha producido un error en la ejecucion de la consulta: " . $e->getMessage();
         # En este caso hemos mostrado el mensaje de error y además almacenamos en un fichero los errores generados.
         file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
     }
 }
コード例 #10
0
 public static function getDescripcion($idTipoMovimiento)
 {
     $coneccion = SPDO::singleton();
     try {
         $consulta = $coneccion->query("SELECT descripcion FROM tipo_movimiento WHERE id_tipo_movimiento = {$idTipoMovimiento};");
         $resultado = $consulta->fetch(PDO::FETCH_ASSOC);
         return $resultado['descripcion'];
     } catch (PDOException $e) {
         echo "Se ha producido un error en la ejecucion de la consulta: " . $e->getMessage();
         # En este caso hemos mostrado el mensaje de error y además almacenamos en un fichero los errores generados.
         file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
     }
 }
コード例 #11
0
 static function getListaAmbitosTematicos()
 {
     $coneccion = SPDO::singleton();
     try {
         $consulta = $coneccion->query("SELECT id_ambito_tematico,descripcion FROM ambito_tematico");
         $resultado = $consulta->fetchAll(PDO::FETCH_ASSOC);
         $i = 0;
         foreach ($resultado as $var) {
             $response[$i]['id_ambito_tematico'] = $var['id_ambito_tematico'];
             $response[$i]['descripcion'] = utf8_encode($var['descripcion']);
             $i++;
         }
     } catch (PDOException $e) {
         echo "Se ha producido un error en la ejecucion de la consulta: " . $e->getMessage();
         # En este caso hemos mostrado el mensaje de error y además almacenamos en un fichero los errores generados.
         file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
     }
     return $response;
 }
コード例 #12
0
ファイル: Bitacora.class.php プロジェクト: jlegrand88/sigpro
 public function save()
 {
     $coneccion = SPDO::singleton();
     if ($this->idBitacora) {
         $sql = "UPDATE bitacora SET " . "id_proyecto = {$this->idProyecto}," . "id_usuario = {$this->idUsuario}," . "id_accion = {$this->idAccion}," . "fecha_creacion = '{$this->fechaCreacion}'," . "observacion = '{$this->observacion}' " . "WHERE id_bitacora = {$this->idBitacora} ;";
     } else {
         $sql = "INSERT INTO bitacora(id_proyecto, id_usuario, id_accion, fecha_creacion,observacion) VALUES(" . "{$this->idProyecto}, {$this->idUsuario}, {$this->idAccion}, '{$this->fechaCreacion}', '{$this->observacion}');";
     }
     try {
         $consulta = $coneccion->prepare($sql);
         $resultado = $consulta->execute();
         if ($this->idBitacora) {
             return $resultado;
         } else {
             return $coneccion->lastInsertId();
         }
     } catch (PDOException $e) {
         echo "Se ha producido un error en la ejecucion de la consulta: " . $sql . "</br>" . $e->getMessage() . "</br>";
         # En este caso hemos mostrado el mensaje de error y además almacenamos en un fichero los errores generados.
         file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
     }
 }
コード例 #13
0
 /**
  * Update information in data-base (insert/update query)
  *
  * @param string $sReq Update SQL request
  * @param array $aData The list of data to be updated
  * @param string $sMsg Specific message (not standard message, ex: "Operation performed successfully")
  * @param string $slinkOK Link to return in initial page.
  * @param boolean $bMsgResult true:display result DB; false : don't display message
  */
 public function executeDbQuery($sReq, $aData, $sMsg, $slinkOk, $bMsgResult = '')
 {
     $update = SPDO::getInstance()->prepare($sReq);
     foreach ($aData as $key => $value) {
         foreach ($value as $cle => $val) {
             if ($cle == 'type') {
                 $type = $val;
             } elseif ($cle != 'type') {
                 $bindName = $cle;
                 $bindValue = $val;
                 // if it's not PDO::PARAM_STR (PDO::PARAM_LOB, for example)
                 if ($type != 2) {
                     $update->bindValue($cle, $val, $type);
                 } elseif ($type == '' or $type = 2) {
                     $update->bindValue($cle, $val);
                 }
             }
         }
     }
     try {
         $resultOK = $update->execute();
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
     if (!isset($resultOK)) {
         $resultOK = false;
     }
     if ($bMsgResult) {
         $aMsg = $this->getItemTransation('BLOG', 'BACK', Admin::$lang, 'MSG_DB_RESULT');
         if ($resultOK) {
             $this->DisplayResultRqt($resultOK, $slinkOk, $aMsg[Admin::$lang]['ok_return'], '');
         } else {
             $this->DisplayResultRqt($resultOK, $slinkOk, '', $aMsg[Admin::$lang]['ko_return']);
         }
     }
     return $resultOK;
 }
コード例 #14
0
 /**
  * Transactions research sort by :
  *
  * @param string $search_mod module filtering parameter
  * @param string $search_lang langauge filtering parameter
  * @param string $search_office back or front filtering parameter
  * @param string $search_type Type filtering parameter
  * @return array filtred translation
  */
 public function getSearchTranslations($search_mod, $search_lang, $search_office, $search_type)
 {
     $where = '';
     if ($search_mod != 'ALL') {
         $where = "module='{$search_mod}'";
     }
     if ($search_lang != 'ALL' && $where != '') {
         $where .= " and lang='{$search_lang}'";
     } elseif ($search_lang != 'ALL' && $where == '') {
         $where = "lang='{$search_lang}'";
     }
     if ($search_office != 'ALL' & $where != '') {
         $where .= " and office='{$search_office}'";
     } elseif ($search_office != 'ALL' & $where == '') {
         $where = "office='{$search_office}'";
     }
     if ($search_type != 'ALL' & $where != '') {
         $where .= " and type='{$search_type}'";
     } elseif ($search_type != 'ALL' & $where == '') {
         $where = "type='{$search_type}'";
     }
     if ($where == '') {
         $sReq = "SELECT * FROM adm_translation order by description";
     } else {
         $sReq = "SELECT * FROM adm_translation WHERE {$where} order by description";
     }
     $result = SPDO::getInstance()->query($sReq);
     $aTrans = $result->fetchAll(PDO::FETCH_ASSOC);
     return $aTrans;
 }
コード例 #15
0
ファイル: Usuario.class.php プロジェクト: jlegrand88/sigpro
 public function savePassword()
 {
     $coneccion = SPDO::singleton();
     if ($this->idUsuario) {
         $sql = "UPDATE usuario SET " . " password = '******' " . " WHERE id_usuario = {$this->idUsuario}; ";
     }
     try {
         $consulta = $coneccion->prepare($sql);
         $resultado = $consulta->execute();
     } catch (PDOException $e) {
         echo "Se ha producido un error en la ejecucion de la consulta: " . $sql . "</br>" . $e->getMessage() . "</br>";
         # En este caso hemos mostrado el mensaje de error y además almacenamos en un fichero los errores generados.
         file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
     }
 }
コード例 #16
0
ファイル: enqueteController.php プロジェクト: benzirab/SMT
 * Created by PhpStorm.
 * User: Ach-Khalil
 * Date: 19/08/15
 * Time: 10:10
 */
session_start();
include '../Models/SPDO.php';
$idBde = $_SESSION['immatricule'];
if (isset($_POST['inserer'])) {
    //$dt=$_POST['dt'];
    $sjt = $_POST['sjt'];
    $cmt = $_POST['cmt'];
    $sct = $_POST['sct'];
    $mrq = $_POST['mrq'];
    $requete = "INSERT INTO `SMT`.`remontee_terrain` (`id`, `date`, `idbde`, `sujet`, `commentaire`, `Secteur`, `Marque`)  VALUES (NULL,CURRENT_TIMESTAMP , {$idBde},'{$sjt}','{$cmt}','{$sct}','{$mrq}')";
    $reponse = SPDO::getInstance()->exec($requete);
    if ($reponse == 1) {
        $_SESSION['enquete'] = true;
        ?>
        <script>
            var obj = 'window.location.replace("http://localhost/Stage_SMT/Views/pages/Enquete.php");';
            setTimeout(obj,1000);
        </script>
        <?php 
    } else {
        $_SESSION['enquete'] = false;
        ?>
        <script>

            var obj = 'window.location.replace("http://localhost/Stage_SMT/Views/pages/Enquete.php");';
            setTimeout(obj,1000);
コード例 #17
0
ファイル: commande.php プロジェクト: benzirab/SMT
    }
}
?>
                </select>
                    <input id="idClient" value="<?php 
echo $_GET['id'];
?>
" hidden>
                    <button type="submit" name="submit" id="valos" hidden>Valider une commande</button>
            </form>
                </div>
                <div class="col-sm-12">
                <label for="select" class="col-sm-6 control-label text-primary">Mode de paiement</label>
                <select class="form-control col-sm-6 input-sm" id="modePaiement" name="site">
                    <?php 
$reponseDelai = SPDO::getInstance()->query("select * from Client WHERE idClient = {$idClient}");
$row = $reponseDelai->fetch();
if ($row['delaiDePaiment'] == 30) {
    ?>
                        <option value="especes">Espèces</option>
                        <option value="cheque_30_jours">Chèque 30 Jours</option>
                        <option value="cheque_3_jours">Chèque 3 Jours</option>
                        <option value="cheque_7_jours">Chèque 7 Jours</option>
                        <?php 
} else {
    if ($row['delaiDePaiment'] == 7) {
        ?>
                            <option value="especes">Espèces</option>
                            <option value="cheque_3_jours">Chèque 3 Jours</option>
                            <option value="cheque_7_jours">Chèque 7 Jours</option>
                            <?php 
コード例 #18
0
ファイル: Commande.php プロジェクト: benzirab/SMT
 /**
  * @param $mois
  * @param $idBDE
  * @return mixed
  *
  */
 public static function caMensuelBDE($mois, $idBDE)
 {
     $query = "SELECT SUM(`total`) as ca FROM commande WHERE MONTH(`date`) = " . $mois . " and idbde =" . $idBDE;
     $reponse = SPDO::getInstance()->query($query);
     return $reponse->fetch();
 }
コード例 #19
0
 public function __construct()
 {
     $this->db = SPDO::singleton();
 }
コード例 #20
0
 /**
  * Read "blog_conf" in database (The blog configuration parameters)
  * and feed classe attributs
  *
  */
 public function ReadBlogConfig()
 {
     $sReq = 'SELECT * FROM blog_config';
     $sRequete = SPDO::getInstance()->query($sReq);
     $aRequete = $sRequete->fetch(PDO::FETCH_ASSOC);
     $this->aff_xs = $aRequete['aff_xs'];
     $this->aff_sm = $aRequete['aff_sm'];
     $this->aff_md = $aRequete['aff_md'];
     $this->aff_lg = $aRequete['aff_lg'];
     $this->art_page = $aRequete['nbr_art_page'];
     $this->ctrl_comm = $aRequete['control_comm'];
     $this->mail_exp = $aRequete['email_from'];
     $this->mail_obj = $aRequete['email_objet'];
     $this->mail_txt = $aRequete['email_text'];
     $this->name_exp = $aRequete['name_from'];
 }
コード例 #21
0
 public function __construct()
 {
     $this->instance = SPDO::getInstance();
 }
コード例 #22
0
ファイル: Inbox.class.php プロジェクト: jlegrand88/sigpro
 public function save()
 {
     $coneccion = SPDO::singleton();
     if ($this->idInbox) {
         $sql = "UPDATE inbox SET " . "id_proyecto = {$this->idProyecto}," . "id_emisor = {$this->idEmisor}," . "id_destinatario = {$this->idDestinatario}," . "id_accion = {$this->idAccion}," . "fecha_recepcion = '{$this->fechaRecepcion}'," . "fecha_despacho = '{$this->fechaDespacho}' " . "WHERE id_inbox = {$this->idInbox} ;";
     } else {
         if (isset($this->fechaRecepcion) && $this->fechaRecepcion != "") {
             $sql = "INSERT INTO inbox(id_proyecto, id_emisor,id_destinatario,id_accion, fecha_despacho,fecha_recepcion) VALUES(" . "{$this->idProyecto}, {$this->idEmisor}, {$this->idDestinatario}, {$this->idAccion}, '{$this->fechaDespacho}', '{$this->fechaRecepcion}');";
         } else {
             $sql = "INSERT INTO inbox(id_proyecto, id_emisor,id_destinatario,id_accion, fecha_despacho) VALUES(" . "{$this->idProyecto}, {$this->idEmisor}, {$this->idDestinatario}, {$this->idAccion}, '{$this->fechaDespacho}');";
         }
     }
     try {
         $consulta = $coneccion->prepare($sql);
         $resultado = $consulta->execute();
         if ($this->idProyecto) {
             return $resultado;
         } else {
             return $coneccion->lastInsertId();
         }
     } catch (PDOException $e) {
         echo "Se ha producido un error en la ejecucion de la consulta: " . $sql . "</br>" . $e->getMessage() . "</br>";
         # En este caso hemos mostrado el mensaje de error y además almacenamos en un fichero los errores generados.
         file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
     }
 }
コード例 #23
0
ファイル: gameSavesDB.php プロジェクト: jcaillon/battle-code
if (!$req->execute(array('id' => $id, 'server' => $server))) {
    die;
}
$data = $req->fetch()['game'];
$rowExists = strlen($data) > 0;
# POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $data = json_encode(array('method' => 'POST', 'id' => $id, 'server' => $server, 'post' => $_POST['data'], 'exists' => $rowExists), JSON_PRETTY_PRINT);
    if ($rowExists) {
        $req = SPDO::getInstance()->prepare('UPDATE gamesaves SET game = :game WHERE id = :id AND server = :server');
        $req->execute(array('id' => $id, 'server' => $server, 'game' => $_POST['data']));
        if ($req->rowCount() < 1) {
            die;
        }
    } else {
        $req = SPDO::getInstance()->prepare('INSERT INTO gamesaves(id, server, game) VALUES(:id, :server, :game)');
        $req->execute(array('id' => $id, 'server' => $server, 'game' => $_POST['data']));
        if ($req->rowCount() < 1) {
            die;
        }
    }
    # GET
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if (!$rowExists) {
        $data = "{}";
    }
} else {
    die;
}
# JSON if no callback
if (!isset($_GET['callback'])) {
コード例 #24
0
ファイル: produits.php プロジェクト: benzirab/SMT
<?php

include_once '../jcart/JCart.php';
if (isset($_POST['site'])) {
    $marque = $_POST['site'];
    $sql = "SELECT * from Produits where Marque LIKE '{$marque}'";
    $reponse2 = SPDO::getInstance()->query($sql);
    while ($row = $reponse2->fetch()) {
        ?>
        <div class="well col-sm-4" style="background-color: white;width:220px;margin-left:17px">

        <form method="post" action="" class="jcart">
            <fieldset>
                <input type="hidden" name="jcartToken"
                       value="<?php 
        echo $_SESSION['jcartToken'];
        ?>
"/>
                <input type="hidden" name="my-item-id" value="<?php 
        echo $row['id'];
        ?>
"/>
                <input type="hidden" name="my-item-name"
                       value="<?php 
        echo utf8_encode($row['nomProduit']);
        ?>
"/>
                <input type="hidden" name="my-item-price" value="<?php 
        echo $row['prix'];
        ?>
"/>
コード例 #25
0
ファイル: Client.php プロジェクト: benzirab/SMT
 public static function getClient($idClient)
 {
     $query = "Select * from Client WHERE id = {$idClient}";
     return SPDO::getInstance()->query($query);
 }
コード例 #26
0
ファイル: Game.php プロジェクト: jcaillon/battle-code
 public static function addTeamInGame($gameId)
 {
     $req = SPDO::getInstance()->prepare('UPDATE game SET nbTeam = nbTeam + 1 WHERE gameId = :gameId');
     $req->execute(array('gameId' => $gameId));
 }
コード例 #27
0
function rollbackAndDie()
{
    SPDO::getInstance()->rollBack();
    die;
}
コード例 #28
0
 public function selectOneCategory($id_cat)
 {
     $aResult = SPDO::getInstance()->query("select * from product_categories where id_cat={$id_cat}");
     return $select = $aResult->fetch(PDO::FETCH_ASSOC);
 }
コード例 #29
0
    $sReq = "SELECT * FROM blog_comments WHERE id_com={$id}";
} elseif ($type == 'rep') {
    $sReq = "SELECT * FROM blog_reply WHERE id_rep={$id}";
}
//Recherche de la valeur du jeton
$sRequete = SPDO::getInstance()->query($sReq);
$aResult = $sRequete->fetch(PDO::FETCH_ASSOC);
if ($aResult['jeton'] == $t) {
    $oAdmin->DisplayResultRqt(TRUE, 'blog.php', $aMsg[$lang]['msg_valid_email'], '');
    $val_confirm = 1;
    if ($type == 'com') {
        $sReq = "UPDATE blog_comments SET email_valid = :val WHERE id_com={$id}";
    } elseif ($type == 'rep') {
        $sReq = "UPDATE blog_reply SET email_valid = :val WHERE id_rep={$id}";
    }
    $update = SPDO::getInstance()->prepare($sReq);
    $update->bindValue(':val', $val_confirm);
    try {
        $result = $update->execute();
    } catch (PDOException $e) {
        echo $e->getMessage();
    }
} else {
    $oAdmin->DisplayResultRqt(FALSE, 'blog.php', '', $aMsg[$lang]['msg_notvalid_email']);
}
?>

    </body>

</html>
コード例 #30
0
ファイル: Team.php プロジェクト: jcaillon/battle-code
 public static function nbOfTeamPlayedThisRound($gameId, $round)
 {
     $req = SPDO::getInstance()->prepare('SELECT COUNT(DISTINCT sourceTeamId) AS numb FROM action WHERE gameId = :gameId AND round = :round');
     $req->execute(array('gameId' => $gameId, 'round' => $round));
     return intval($req->fetch()['numb']);
 }