google_forms/application/models/Frontend_model.php

30 lines
955 B
PHP
Raw Normal View History

2024-07-16 12:29:59 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Frontend_model extends CI_Model {
2024-07-19 10:46:18 +00:00
public function getforms()
{
// Get the user_id from session
$user_id = $this->session->userdata('user_id');
// Ensure user_id is set
if (!$user_id) {
return []; // Return an empty array if user_id is not available
}
// Filter forms by user_id
$this->db->where('user_id', $user_id); // Assuming 'user_id' is the column name in the 'forms' table
$query = $this->db->get('forms');
return $query->result(); // Return the result as an array of objects
2024-07-16 12:29:59 +00:00
}
public function deleteForm($id){
return $this->db->delete('forms', ['id' => $id]);
}
2024-07-19 10:46:18 +00:00
public function getFormById($form_id)
{
$query = $this->db->get_where('forms', ['id' => $form_id]);
return $query->row_array();
}
2024-07-16 12:29:59 +00:00
}