# Models

This folder contains model files, all the database-related queries will go on these files.

{% code title="bookings\_model.php" %}

```php
<?php
class Bookings_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
    
    /**
    * This function will return the result-set array of bookings.
    * @return Array $result array of bookings.
    */  
    function get_bookings()
    {
        $company_id = $this->session->userdata('current_company_id');
        
         $sql_query ="SELECT b.rate,b.booking_id,bb.room_id,bb.check_in_date, bb.check_out_date, r.room_name, c.customer_name, c.email
                from booking b, booking_block bb, room r, customer c
                where b.booking_id=bb.booking_id 
                and bb.room_id=r.room_id
                and b.booking_customer_id=c.customer_id
                and b.company_id=$company_id order by b.booking_id DESC LIMIT 20" ;
        
        $booking_data = $this->db->query($sql_query);    
            if ($this->db->_error_message()) 
            {
                show_error($this->db->_error_message());
            }
         $result = $booking_data->result_array();       
        
        return $result;
    }
   
      /**
    * This function will return the result-set array of customers.
    * @return Array $result array of customers.
    */  
    function get_customer_list()
    {
        $company_id = $this->session->userdata('current_company_id');
        $query = "SELECT customer_name, email, address,phone FROM customer where company_id = $company_id order by customer_id DESC LIMIT 20";
        $customer = $this->db->query($query);    
        if ($this->db->_error_message()) 
        {
            show_error($this->db->_error_message());
        }
        
        $result = $customer->result_array();       
        return $result;
    }  
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.minical.io/build-an-extension/build-your-first-extension/models.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
