Priority File Manager

📁 public_html
Base Directory:
/home/ecedu/public_html/new/Models
NameTypeSizeActions
📁 .. Folder -
📄 BasicManager.php File 2087
Edit Download
📄 DB.php File 935
Edit Download
📄 DetailsManager.php File 4312
Edit Download
📄 DeviceAuth.php File 698
Edit Download
📄 Functions.php File 6774
Edit Download
📄 ImageManager.php File 2862
Edit Download
📄 News.php File 13517
Edit Download
📄 NewsModel.php File 9523
Edit Download

View File: BasicManager.php

<?php

require_once __DIR__ . '/DB.php'; // كلاس Singleton يوفر اتصال PDO مثلاً

class BasicManager
{
    protected $db;

    public function __construct()
    {
        $this->db = DB::instance()->getConnection();
    }

   public function getDb(): PDO
   {
     return $this->db;
   }
    
    public function insertOrUpdateBasic(int $typeId, string $desc ): bool
    { 
        $sql = "
           INSERT INTO dbs_social_media (type_id, text_title, text_description)
           VALUES (:tid, '', :desc )
           ON DUPLICATE KEY UPDATE text_description = VALUES(text_description) 
        ";

        $stmt = $this->db->prepare($sql);
        $stmt->bindValue(':tid',  $typeId, PDO::PARAM_INT);
        $stmt->bindValue(':desc', $desc,   PDO::PARAM_STR); 

        return $stmt->execute();
    }

    public function insertOrUpdateNewBasic(int $typeId, string $desc, string $desc1, string $desc2, int $userId, int $type): bool
    {
        $table="";
        if($type==1)
         $table="dbs_about_us";
        else if($type==2)
         $table="dbs_contact_us";
        else if($type==3)
         $table="dbs_social_media";
        $sql = "
           INSERT INTO $table (type_id, text_title, text_description, text_description1, text_description2, img_ext, user_id)
           VALUES (:tid, '', :desc, :desc1, :desc2, '', :uid)
           ON DUPLICATE KEY UPDATE
               text_description = VALUES(text_description),
               text_description1 = VALUES(text_description1),
               text_description2 = VALUES(text_description2),
               user_id          = VALUES(user_id)
        ";

        $stmt = $this->db->prepare($sql);
        $stmt->bindValue(':tid',  $typeId, PDO::PARAM_INT);
        $stmt->bindValue(':desc', $desc,   PDO::PARAM_STR);
        $stmt->bindValue(':desc1', $desc1,   PDO::PARAM_STR);
        $stmt->bindValue(':desc2', $desc2,   PDO::PARAM_STR);
        $stmt->bindValue(':uid',  $userId, PDO::PARAM_INT);

        return $stmt->execute();
    }
}