new user help |
[eluser]B3ll4triX[/eluser]
I am use CI for the first time. I have a poblem. I have 2 table article and category. In category table, i have 3 fields (category_id, name, description). In article table, i have 4 fields (id, headline, description, category_id). The problem is, how to write the MVC in CI, if the finished look like this: headline: The CI Contructor description: --- description here --- category_name: --- name of category here --- headline: The CI Contructor 2 description: --- description here 2 --- category_name: --- name of category here 2 --- . : I am always write 2 looping in this case, <?php include('./adodb/adodb.inc.php'); $sql = "SELECT * FROM article"; $query = $conn->Execute($sql); while(!$query->EOF){ echo "headline: ".$query->fields[1]."<br>"; echo "description: ".$query->fields[2]."<br>"; $sql2 = "SELECT category_id, name FROM category WHERE category_id = '".$conn->fields[3]."'"; $query2 = $conn->Execute($sql2); echo "category_name: ".$query2->fields[1]; echo "<br><br>"; $conn->MoveNext(); } ?> - thank's b4 -
[eluser]Derek Allard[/eluser]
I split this off from the other thread since it wasn't very related. Welcome to CodeIgniter!
[eluser]Pascal Kriete[/eluser]
I don't really know how to do it with adodb (have you tried ActiveRecord?). For a normal sql query I would do: Code: $sql = "SELECT article.headline, article.description, category.name Or using ActiveRecord: Code: $this->db->select(article.headline, article.description, category.name); |
Welcome Guest, Not a member yet? Register Sign In |