Propel custom sql for view tables(为视图表推进自定义 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为视图表推进自定义 sql
基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
