get_results("SELECT * FROM " . $wpdb->prefix . "abctest_main WHERE id_test = " . $_GET['parentid']);
?>
';
echo '';
echo '';
echo '';
}
public static function mainform($rows, $action)
{
$actions = array('' => '',
'insert' => '?page=options&parentid=' . $_GET['parentid'] . '&do=insert',
'edit' => '?page=options&parentid=' . $_GET['parentid'] . '&do=update');
?>
«
prefix . "abctest_options";
$fields = self::dbfields();
$rows_affected = $wpdb->insert( $table_name, $fields );
if ($rows_affected > 0) {
self::$message = __('Data were entered.','abctest_lbl');
self::$msgstatus = 'updated';
} else {
self::$message = __('There was an error! Can not insert data.');
self::$msgstatus = 'error';
}
return $rows_affected;
}
public static function edit()
{
global $wpdb;
$sql = sprintf("SELECT * FROM %sabctest_options WHERE id_option = %d", $wpdb->prefix, $_GET['id']);
$rslt = $wpdb->get_results($sql);
self::mainform($rslt, $_GET['do']);
}
public static function update()
{
global $wpdb;
$table_name = $wpdb->prefix . "abctest_options";
$fields = self::dbfields();
$rows_affected = $wpdb->update( $table_name, $fields, array('id_option' => $_POST['irecord']), NULL, array('%d') );
if ($rows_affected > 0) {
self::$message = __('The data have been updated.','abctest_lbl');
self::$msgstatus = 'updated';
} else {
self::$message = __('There was an error! Can not insert data.','abctest_lbl');
self::$msgstatus = 'error';
}
return $rows_affected;
}
public static function delete()
{
global $wpdb;
$sql = sprintf("DELETE FROM %sabctest_options WHERE id_option = %d", $wpdb->prefix, $_GET['id']);
$wpdb->query($sql);
self::$message = __('The data have been deleted.','abctest_lbl');
self::$msgstatus = 'updated';
// Implementare cancellazione immagine
/*
$deletefile = self::$uploadfolder . $_GET['file'];
if ( file_exists( $deletefile ) ) {
unlink($deletefile);
}
*/
}
public static function dbfields()
{
$arrFields = array('id_test' => $_GET['parentid'],
'options_introduction' => $_POST['options_introduction'],
'option_a' => $_POST['option_a'],
'option_b' => $_POST['option_b'],
'option_c' => $_POST['option_c']);
//'bgimage' => $_FILES['bgimage']['name'],
/*
$upfile = self::upload();
if ( ! empty($upfile) ) {
$fup = array("bgimage" => $upfile);
$arrFields = array_merge((array) $arrFields, (array) $fup);
}
*/
return $arrFields;
}
public static function reorder()
{
global $wpdb;
$table_name = $wpdb->prefix . "abctest_options";
$arrItems = $_POST['recordorder'];
for ($j = 0; $j < count($arrItems); $j++ ) {
$SQLupdate = " UPDATE $table_name SET options_order = " . ($j + 1) . " WHERE id_option = " . $arrItems[$j];
$wpdb->query($SQLupdate);
}
self::$message = __("The order of the data was stored.",'abctest_lbl');
self::$msgstatus = 'updated';
}
} // end abcTestOptions
?>