0

So I'm trying to execute this query:

SELECT r.refID AS rID, avgrat FROM rcc r;

with Zend_Db_Select

So I have this code:

$sql = new Zend_Db_Select($db);
$sql->from(array("r" => "rcc"), array("rID" => "refID"), "avgrat");
$stmt = $db->query($sql);
$result = $stmt->fetchAll();

But then I get mysql db error which complains that Base table or view not found: 1146 table avgrat.rcc doesn't exist..

even though the table does indeed exist

what did I do wrong?

1
  • Try your sql in command line. Is it works? Commented Nov 18, 2011 at 6:21

2 Answers 2

2

The problem may be that you're passing avgrat as the third parameter to from(), which is actually for setting the $schema. So, unless your database is actually named avgrat then try:

$sql->from(array('r' => 'rcc'), array('rID' => 'refID', 'avgrat'));
Sign up to request clarification or add additional context in comments.

Comments

0

Is this table exist in the database?

Try this

$sql = new Zend_Db_Select($db);
$sql->from(array("r" => "rcc"), array("refID AS rID"), "avgrat");
$stmt = $db->query($sql);
$result = $stmt->fetchAll()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.