Avoid booking overlap situation in PHP
<p>I have an application that allows users to book entertainment facilities. Users can select a start date (05/05/2022) and an end date (05/08/2022) and then send the data through the database. </p>
<p><em>But</em>, <strong>(Question)</strong>I have a user who wants to book the same facility. They select a start date (05/03/2022) and an end date (05/06/2022). My goal is to prevent users from booking facilities with an end date between existing booking dates. </p>
<p><strong>(Implemented)</strong>I can achieve this by disabling the required amenities for the reservation if the start and end dates fall between existing reservation dates. I've completed the SQL query: </p>
<pre class="brush:php;toolbar:false;">"SELECT * FROM reservations WHERE facility = :facility AND :begDate BETWEEN begDate AND endDate AND :endDate BETWEEN begDate AND endDate";</pre>
<p>What are some suggestions for handling <strong>ISSUE</strong> in queries while handling <strong>ACHIEVED</strong>? </p>