WordPress SQL ( Table Inserts )
Just Selects all rows
global $wpdb;
$table_name = "yolo_molo";
$user_id = $args['user_id'];
$sql = "SELECT * FROM " .$table_name." WHERE pilot_id = $user_id";
$sql = $wpdb->prepare( "SELECT * FROM " .$table_name." WHERE pilot_id = %d", $user_id );
$all_results = $wpdb->get_results($sql, ARRAY_A);
var_dump($all_results);
Update Table
$wpdb->update(
$table_name,
array(
'icon' => $icon,
'name' => $track_name,
'content' => $track_content,
'sponsor_link' => $sponsor_link
),
array( 'pilot_id' => $user_id ),
array(
'%s',
'%s',
'%s',
'%s',
)
);
OR……
$column_name_values['icon'] = $icon;
$column_name_values['name'] = $track_name;
$column_name_values['content'] = $track_content;
$column_name_wheres['pilot_id'] = $user_id;
$data_types[] = "%s";
$data_types[] = "%s";
$data_types[] = "%s";
$wpdb->update( $table_name, $column_name_values, $column_name_wheres, $data_types );
Insert Row
$wpdb->insert(
$table_name,
array(
'pilot_id' => $pilot_id,
'icon' => $icon,
'name' => $track_name,
'content' => $track_content,
'sponsor_link' => $sponsor_link,
'active' => $active,
),
array(
'%d',
'%s',
'%s',
'%s',
'%s',
'%s'
)
);