使用doctrine 1.2创建查询,其中表名需要来自数据库

Is it any possibility to create query with doctrine (symfony 1.4) in which I defined table name from database (not model class from schema.yml) in from clause?

For example:

in schema.yml I have model class

StaticPage:
connection: doctrine
tableName: static_page
columns:
...

my query is as following:

$item = Doctrine_Query::create();
$item->query("SELECT * FROM StaticPage WHERE id = ".$id);
$change = $item->fetchOne();
$change->setPublished(true);
$change->save();

In this query instead StatigPage I need static_page (tableName)...

Thanks...

Other way of Fracsi's solution:

$item = Doctrine::getTable("StaticPage")->findOneById($id);
    if($item instanceof StaticPage) {
        $item->setPublished(true);
        $item->save();
    }

Always use your model/ORM. There are few cases in which Doctrine can't build the correct query syntax and you have to write sql on your own.

Generalized version: (pass the model name through parameter (e.g. $sf_request)

$item = Doctrine::getTable($model_name)->findOneById($id);
$item->setPublished(true);
$item->save();