46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
|
|
$dbDetails = array(
|
|
'host' => 'localhost',
|
|
'user' => 'root',
|
|
'pass' => 'XmRTSMQ9',
|
|
'db' => 'php_crud'
|
|
);
|
|
|
|
|
|
$table = 'general';
|
|
|
|
$primaryKey = 'id';
|
|
|
|
|
|
$columns = array(
|
|
array('db' => 'id', 'dt' => 0),
|
|
array('db' => 'instruction', 'dt' => 1),
|
|
array('db' => 'input', 'dt' => 2),
|
|
array('db' => 'output', 'dt' => 3),
|
|
array(
|
|
'db' => 'created_at',
|
|
'dt' => 4,
|
|
'formatter' => function ($d, $row) {
|
|
return date('js M Y', strtotime($d));
|
|
}
|
|
),
|
|
array(
|
|
'db' => 'id',
|
|
'dt' => 5,
|
|
'formatter' => function ($d, $row) {
|
|
return '<a href="edit.php?id=' . $d . '" class="btn btn-secondary m-2">Editar</a>
|
|
<a href="delete_dataset.php?id=' . $d . '" class="btn btn-danger" onclick="return confirm(\'¿Estás seguro de que deseas eliminar este registro?\');">Eliminar</a>';
|
|
}
|
|
)
|
|
);
|
|
|
|
|
|
require('ssp.class.php');
|
|
|
|
|
|
// Output data as json format
|
|
echo json_encode(
|
|
SSP::simple($_GET, $dbDetails, $table, $primaryKey, $columns)
|
|
);
|