new user help

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,
$sql = "SELECT * FROM article";
$query = $conn->Execute($sql);
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>";


- 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:
$sql = "SELECT article.headline, article.description,
FROM article, category
WHERE article.category_id = category.category_id";

Or using ActiveRecord:
$this->db->select(article.headline, article.description,;
$this->db->from('article, category');
$this->db->where("article.category_id = category.category_id");
$query = $this->db->get();

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.