PHP &

0 Cevap php

Tamam işte ben kullanıyorum kodudur

    function AddProducts($aTitle, $aDescription, $aPrice, $aQty, $aPhoto)
    {

        try {
            $stmt = $this->pdo->prepare("INSERT INTO products(title, price, description, qty, photo) VALUES(:title, :price, :description, :qty, :photo)");
            if(!$stmt){
                $err = $this->pdo->errorInfo();
                throw new RuntimeException('PRODUCT INSERT FAILED: '.$err[2]);
            }
            $stmt->bindValue(':title', $this->title, PDO::PARAM_STR);
            $stmt->bindValue(':description', $this->description, PDO::PARAM_STR);
            $stmt->bindValue(':price', $this->price, PDO::PARAM_INT);
            $stmt->bindValue(':qty', $this->qty, PDO::PARAM_INT);
            $stmt->bindValue(':photo', $this->photo, PDO::PARAM_STR);
            $stmt->execute();
        }catch (PDOException $e) {
            echo $e->getMessage();
        }


    }

$addProducts = $database->AddProducts('Ford Mustang', 'This is a Descriptiom', 299.99, 1, 'images/includes/5.jpg');

Veritabanı sınıfı ve veritabanı arama fonksiyonu çalışır. Bunu işaret lütfen zekalı şey nokta varsa da, ben öğrenmeye çalışıyorum.

0 Cevap