Esempio n. 1
0
 public static function removeProduct($barcode, $expiration)
 {
     $mysql = new Mysql();
     $update = $mysql->update("delete from product where barcode='{$barcode}' and expiration='{$expiration}'");
     $mysql->closeConnection();
     return $update;
 }
Esempio n. 2
0
 public static function save(Music $music)
 {
     $data = ['id' => $music->id, 'band' => $music->band_name, 'album' => $music->album_name, 'year' => $music->year];
     if ($data['id'] !== null) {
         Mysql::update('UPDATE music SET band_name = ?, album_name = ?, year = ? WHERE id = ?', [$data['band'], $data['album'], $data['year'], $data['id']]);
     } else {
         Mysql::insert('INSERT INTO music (band_name, album_name, year) VALUES (?, ?, ?)', [$data['band'], $data['album'], $data['year']]);
     }
 }
Esempio n. 3
0
 function save()
 {
     $champsUpdate = array('nom' => $_REQUEST['nom'], 'adresse' => $_REQUEST['adresse'], 'cp' => $_REQUEST['cp'], 'ville' => $_REQUEST['ville'], 'telephone' => $_REQUEST['telephone'], 'email' => $_REQUEST['email'], 'site_web' => $_REQUEST['site_web'], 'nom_contact' => $_REQUEST['nom_contact'], 'prenom_contact' => $_REQUEST['prenom_contact'], 'tel_contact' => $_REQUEST['tel_contact'], 'portable_contact' => $_REQUEST['portable_contact'], 'email_contact' => $_REQUEST['email_contact'], 'temperature' => $_REQUEST['temperature'], 'dirigeant' => $_REQUEST['dirigeant'], 'naf' => $_REQUEST['naf'], 'autre' => $_REQUEST['autre']);
     $champsInsert = $champsUpdate;
     $id = $_REQUEST['id'];
     if ($id) {
         // Update
         Mysql::update($this->table, $champsUpdate, "WHERE `id` = '%d'", $id);
     } else {
         // Insert
         $id = Mysql::insert($this->table, $champsInsert);
     }
     $this->redirect($id);
     // Rechargement de la page avec l'Bien courant
 }
Esempio n. 4
0
    foreach ($KeyList as $k => $v) {
        if (!isset($_GET[$v])) {
            $res = ['ok' => 0, 'error' => "param invalid "];
            echo json_encode($res);
            return;
        }
    }
}
$mysql = new Mysql();
//连接数据库
$myMemcache = new MyMemcache();
if (isset($_GET['footId'])) {
    $_GET['like'] = $myMemcache->get("like" . $_GET['footId']) ? $myMemcache->get("like" . $_GET['footId']) + 1 : 1;
    $_GET['id'] = $_GET['footId'];
    $FootList = array('id', 'like');
    $mysql->update("foot", "like", "{$_GET['like']}", "id", "{$_GET['id']}");
} else {
    $memValue = $myMemcache->get($_GET['url']);
    if ($memValue) {
        $_GET['id'] = $memValue;
        $footprintId = $myMemcache->get($_GET['userId'] . "foot:" . $_GET['id']);
        if ($footprintId) {
            echo json_encode(['ok' => 1, 'data' => [id => $footprintId]]);
            die;
        }
        $_GET['like'] = $myMemcache->get("like" . $_GET['id']) ? $myMemcache->get("like" . $_GET['id']) + 1 : 1;
        $FootList = array('url', 'title', 'id', 'like');
    } else {
        $_GET['like'] = 1;
        $FootList = array('url', 'title');
    }
Esempio n. 5
0
function ModifierLaRencontre($id_rencontre, $id_societe, $date_rencontre, $commentaire, $type_rencontre)
{
    return Mysql::update('rencontre', array('id_societe' => $id_societe, 'date_rencontre' => $date_rencontre, 'commentaire' => $commentaire), "WHERE id = '%d' ", $id_rencontre);
}
Esempio n. 6
0
                $string .= $this->setQuoteStyle($key) . "='" . $this->safeFilter($val) . "'";
            } else {
                $string .= ',' . $this->setQuoteStyle($key) . "='" . $this->safeFilter($val) . "'";
            }
        }
        $sql = 'UPDATE ' . $this->setQuoteStyle($table) . ' SET ' . $string . ($where === NULL ? $where : ' WHERE ' . $where);
        echo $sql;
        //mysql_query ( $sql, $this->_link );
    }
    function delete($table, $where = NULL)
    {
        $sql = 'DELETE FROM ' . $this->setQuoteStyle($table) . ($where == NULL ? $where : ' WHERE ' . $where);
        echo $sql;
        mysql_query($sql, $this->_link);
    }
    function setQuoteStyle($key)
    {
        return '`' . $key . '`';
    }
    function safeFilter($value)
    {
        return mysql_real_escape_string($value, $this->_link);
    }
}
// 创建对象
$bind = array('username' => "1'1", 'password' => "2'1", 'age' => 112, 'sex' => 1);
$db = new Mysql();
$x = $db->connect('localhost', 'root', 'root', 'test');
//var_dump($x);
$db->update('users', $bind, 'id=1');