I’m using the DataTables SSP class. According to my research on the internet, it should be sufficient to add SSP::simple to the end in order to write a where condition. However, I’ve tried it and it still fetches all the data, the condition doesn’t seem to work.
My code is below:
// Veritabanı bağlantı bilgilerini içeren bir dizi oluşturun
$dbDetails = array(
'host' => 'localhost',
'db' => 'sigortav2-1',
'user' => 'root',
'pass' => ''
);
// Veritabanı bağlantısını sağlayın
try {
$db = new PDO('mysql:host=' . $dbDetails['host'] . ';dbname=' . $dbDetails['db'], $dbDetails['user'], $dbDetails['pass']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo "Veritabanı bağlantısı kurulamadı: " . $e->getMessage();
exit;
}
// SSP sınıfını kullanarak DataTables için gereken veri kaynağını oluşturun
$table = 'ihbarlar';
$primaryKey = 'id';
$columns = array(
array('db' => 'id', 'dt' => 0),
array('db' => 'ekleme_tarihi', 'dt' => 1),
array('db' => 'ekleyen_bayi', 'dt' => 2),
array('db' => 'sigorta_sirketi', 'dt' => 3),
array('db' => 'plakasi', 'dt' => 4),
array('db' => 'dosya_numarasi', 'dt' => 5),
array('db' => 'sigortali_ad_soyad', 'dt' => 6),
array('db' => 'durum', 'dt' => 7),
array(
'db' => 'id',
'dt' => 8,
'formatter' => function ($id, $row) {
return '<div class="dropdown"><button class="btn btn-light dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">İşlem <i class="mdi mdi-chevron-down"></i></button><div class="dropdown-menu" aria-labelledby="dropdownMenuButton "><a class="dropdown-item" href="ihbar/ihbar-bilgileri/' . $id . '">Gör/Düzenle</a><a class="dropdown-item" href="javascript<b></b>:void(0);">Yazdır</a><div class="dropdown-divider"></div><a class="dropdown-item text-danger" href="javascript<b></b>:void(0);">Sil</a></div></div>';
}
),
array('db' => 'arac_modeli', 'dt' => 9),
);
// WHERE koşulunu oluşturun
$where = "bayi_id = 'yazılım'";
// SSP sınıfını kullanarak DataTables için gereken veri kaynağını oluşturun
require_once 'SSP.class.php'; // SSP sınıfının dosyasının yolunu doğru şekilde ayarlayın
echo json_encode(
SSP::simple($_GET, $db, $table, $primaryKey, $columns, $where)
);
exit;
According to my research on the internet, it should be sufficient to add SSP::simple to the end in order to write a where condition