title: How to convert MySQL query to PHP code
body: <p>I am trying to get data from database using Codeigniter as framework.</p>
  
  <p>I was able to come up with SQL query for desired result, but since I am not familiar with Codeigniter DB syntax, I am having a trouble. Below is the query that I want to execute. How do I do this in php? </p>
  
  <p>Any advice or suggestion would be appreciated. Thank you.</p>
  
  <pre><code>SELECT A.*, B.*
  FROM
      (SELECT A.*
      FROM DriversInfo as A, InvoiceQueue as B
      WHERE A.CreateTime = B.DriverCreateTime
      AND B.Error &lt;&gt; 1
      GROUP BY A.CreateTime
      UNION
      SELECT DISTINCT A.*
      FROM DriversInfo as A, OrderInfo as B
      WHERE A.CreateTime = B.DriverKey
      AND B.Invoice &lt;&gt; '0') as A
  LEFT JOIN DriversDoc as B
  on A.CreateTime = B.DriverCreateTime
  WHERE B.DriversLicense is null
  OR B.CarRegistration is null
  OR B.BizCertificate is null
  OR B.Insurance is null;
  </code></pre>