Note that there are some explanatory texts on larger screens.

plurals
  1. PODB query not retrieved correctly
    text
    copied!<p>I am using zend framework and my sql to display some data.</p> <p>Query is given below:</p> <pre><code> $table = new Timesheets_Table_Tasks(); $select = $table-&gt;select(true) -&gt;setIntegrityCheck(false) -&gt;join('timesheets_projects', 'timesheets_projects.ID=timesheets_tasks.ProjectID', array()) -&gt;join('timesheets_clients', 'timesheets_clients.ID=timesheets_projects.ClientID', array()) return $this-&gt;filterSelect($select); </code></pre> <p>And the function filterSelect is given below:</p> <pre><code>protected function filterSelect($select) { $select-&gt;where("timesheets_tasks.UserID=?", Zend_Auth::getInstance()-&gt;getIdentity()-&gt;id); foreach($this-&gt;_filters as $filter =&gt; $value) { if(($value == "" || $value == "none") &amp;&amp; $filter != "status") { continue; } switch($filter) { case 'q': $select-&gt;where($this-&gt;_db-&gt;quoteInto('timesheets_tasks.Comment LIKE ?', '%' . $value . '%')); break; case 'after': $select-&gt;where($this-&gt;_db-&gt;quoteInto('timesheets_tasks.Date &gt;= UNIX_TIMESTAMP(STR_TO_DATE(?, "%d/%m/%Y"))', $value)); break; case 'before': $select-&gt;where($this-&gt;_db-&gt;quoteInto('timesheets_tasks.Date &lt;= UNIX_TIMESTAMP(STR_TO_DATE(?, "%d/%m/%Y"))', $value)); break; case 'client': $select-&gt;where($this-&gt;_db-&gt;quoteInto('timesheets_clients.ID = ?', $value)); break; case 'project': $select-&gt;where($this-&gt;_db-&gt;quoteInto('timesheets_tasks.ProjectID = ?', $value)); break; case 'status': $select-&gt;where($this-&gt;_db-&gt;quoteInto('timesheets_tasks.Status = ?', $value)); break; case 'jobtype': $select-&gt;where($this-&gt;_db-&gt;quoteInto('timesheets_tasks.TypeID = ?', $value)); break; } } return $select; } </code></pre> <p>I displayed the query and it displays as:</p> <p><strong>SELECT <code>timesheets_tasks</code>.* FROM <code>timesheets_tasks</code> INNER JOIN <code>timesheets_projects</code> ON timesheets_projects.ID=timesheets_tasks.ProjectID INNER JOIN <code>timesheets_clients</code> ON timesheets_clients.ID=timesheets_projects.ClientID WHERE (timesheets_tasks.UserID='33') AND (timesheets_tasks.Status = 0) ORDER BY <code>date</code> DESC</strong></p> <p>But the query doesn't give the actual data.</p> <p>I think it is an issue with join tables. When I removed the line " ->join('timesheets_clients', 'timesheets_clients.ID=timesheets_projects.ClientID', array())" from the query, the output showed correctly. But I have to select some of the field from the other two tables too. So I need a join property. Any other join can I use to get the column values from the other two tables and get the correct output?</p> <p>I am new to joins. Any help should be appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload