本文介绍了推进用于视图表的自定义SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,propel不会为视图表生成模型,如果您使用reverse任务,它甚至不包括视图表的结构.因此,我别无选择,只能使用自定义查询.我知道该模型是否存在该怎么办:

For some reason propel is not generating model for view tables, it doesn't even include the structure of the view table if you use the reverse task. So I have no option but to use a custom query. That I know how to do if the model exists:

<?php 
    $con = Propel::getConnection(BookPeer::DATABASE_NAME);
    $sql = "complicated query here...";
    $stmt = $con->prepare($sql);
    $stmt->execute();

但是由于propel不会为我的视图表生成模型,所以我不知道该怎么做.我已经尝试过了,但是没用

but since propel does not generate a model for my view table, i don't know how to do that. I've tried this but it doesn't work

<?php 
    $con = Propel::getConnection(MyViewTable::DATABASE_NAME);
    $sql = "SELECT * FROM MyViewTable";
    $stmt = $con->prepare($sql);
    $stmt->execute();

我真的需要这项工作.请帮忙:)

I really need to have this work. Please help :)

推荐答案

$con = Propel::getConnection();

您将获得当前的数据库连接,并且可以进行所需的任何SQL查询,

You will get your current database connection and you can make any sql query you like,

这篇关于推进用于视图表的自定义SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 16:17