CodeIgniter Forums

Full Version: Query returns nothing.... [SOLVED]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Frychiko[/eluser]
I have a query to get a row from a table,
to extract a row with a field = "Accessories - Mouse"

Code:
$this->db->select("*, merchant.name as merchant, ".$this->table.".id as id, category.name as category");
$this->db->join("merchant", "merchant.id = ".$this->table.".merchant_id");
$this->db->join("category", "category.id = ".$this->table.".category_id");
$this->db->where($new_where);

$query = $this->db->get($this->table);


Which converts to this, as tested in phpmyadmin:
Code:
SELECT * , merchant.name AS merchant, merchant_category.id AS id, category.name AS category
FROM (
`merchant_category`
)
JOIN `merchant` ON merchant.id = merchant_category.merchant_id
JOIN `category` ON category.id = merchant_category.category_id
WHERE merchant_category.display = 'Accessories - Mouse'

CI returns nothing:
Code:
echo "search results:".$query->num_rows();

but, phpmyadmin returns a row, which should be the correct result:

Quote:Showing rows 0 - 0 (1 total, Query took 0.0008 sec)


45, Accessories Mouse, Accessories - Mouse, 4, 17, 96, 4, newegg, NewEgg....

What is going on here? It's driving me insane Confused

El Forum

[eluser]Michael Wales[/eluser]
Be sure ActiveRecord is piecing your query together properly:
Code:
$this->output->enable_profiler(TRUE);

El Forum

[eluser]Frychiko[/eluser]
Cheers, Michael.. that helped! turned out to be different!