Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP: What's the way to use an SQL query statement in an MVC-like structure
    primarykey
    data
    text
    <p>I wonder how do we use this in an MVC framework, CakePHP in particular. </p> <pre><code>$query = oci_parse($c, "SELECT * FROM JOB ORDER BY job_title"); oci_execute($query); while($row = oci_fetch_assoc($query)){ $showRowJ .= "&lt;tr&gt;\n"; $showRowJ .= "&lt;td&gt;&lt;a href = 'job_delete.php?jobid=".$row['JOB_ID']."'&gt; Delete &lt;/a&gt;&lt;/td&gt;\n"; $showRowJ .= "&lt;td&gt;&lt;a href = 'job_update.php?jobid=".$row['JOB_ID']."'&gt; ".$row['JOB_ID']." &lt;/a&gt;&lt;/td&gt;\n"; $showRowJ .= "&lt;td&gt;".$row['JOB_TITLE']."&lt;/td&gt;\n"; $showRowJ .= "&lt;td&gt;".$row['REQUEST_DATE']."&lt;/td&gt;\n"; $showRowJ .= "&lt;td&gt;".$row['START_DATE']."&lt;/td&gt;\n"; $showRowJ .= "&lt;td&gt;".$row['NUMBER_OF_DAYS']."&lt;/td&gt;\n"; $showRowJ .= "&lt;td&gt;".$row['STATUS']."&lt;/td&gt;\n"; $showRowJ .= "&lt;td&gt;".$row['CLIENT_ID']."&lt;/td&gt;\n"; $showRowJ .= "&lt;/tr&gt;\n"; } </code></pre> <p>and if for MySQL: (example)</p> <pre><code>$result = mysql_query('SELECT * WHERE 1=1'); if (!$result) { die('Invalid query: ' . mysql_error()); } </code></pre> <p>I'm confused some say it should be in a model and some are using find('all')</p> <blockquote> <p>UPDATE:</p> </blockquote> <p>Hey sorry I meant when we want to query joint tables. The above is just an example when we need to include WHERE 2-3 times for joining tables. </p> <p>Let's say I want to query:</p> <pre><code>SELECT users.name, foods.name FROM users, foods WHERE users.id='1' AND users.id=foods.id </code></pre> <p>Something like above.. How should we do it in CakePHP ? </p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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