[英]server-side SQL include
This is the php version of this question server-side SQL library 这是此问题服务器端SQL库的php版本
Is there a library that can break apart sql into fully server-side logic? 是否有可以将sql分解为完全服务器端逻辑的库?
As an example consider this basic query SELECT table1column1, table2column1 FROM table1, table2 WHERE table1.id = 1 AND table2.table1id = table1.id;
作为示例,请考虑以下基本查询: SELECT table1column1, table2column1 FROM table1, table2 WHERE table1.id = 1 AND table2.table1id = table1.id;
which is ~5x slower than breaking up the SELECT
into 2 SELECT
s SELECT
ing off the PRIMARY
for both, assuming that table2.table1id
is not the PRIMARY
. 这是5倍〜慢于拆散SELECT
成2 SELECT
小号SELECT
荷兰国际集团关闭PRIMARY
两者,假定table2.table1id
不是PRIMARY
。
I would want a library, that in this case, does just that, breaks up the single query into two. 我想要一个在这种情况下可以做到的库,将单个查询分成两个查询。 It doesn't have to parse sql to understand what one wants rather it would probably be best in something like this format basicJoin($table1columnsList, $table2columnsList, $table1name, $table2name, $table1id, $table2table1idColumnName)
. 它不必解析sql就能理解一个人想要什么,而是以这种格式basicJoin($table1columnsList, $table2columnsList, $table1name, $table2name, $table1id, $table2table1idColumnName)
这样的格式最好。
This function would 该功能将
SELECT
the table1
columns specified into an array based upon $table1id
(the PRIMARY
) SELECT
基于$table1id
( PRIMARY
)指定到数组中的table1
列 SELECT
all table2
ids ( table2
's PRIMARY
) and table1id
s into an array and find the proper table2
id SELECT
所有table2
id( table2
的PRIMARY
)和table1id
到数组中,并找到适当的table2
id table2
id above to SELECT
the table2
columns specified into an array (or in the table1
array) 使用上面的table2
id来SELECT
指定到数组(或在table1
数组中)的table2
列 Handling my logic in php only has vastly decreased processing lag and processing lag spikes, but it's tedious writing out all of this logic. 用php处理我的逻辑只会大大减少处理滞后和处理滞后尖峰,但是写出所有这些逻辑很繁琐。
Does it already exist? 它已经存在吗? If so, where? 如果是这样,在哪里?
Many thanks in advance! 提前谢谢了!
If you're into OOP there's Propel - http://propelorm.org/ It handles all the logic and gives you methods like joinWith()
and getThis()
, setThat()
, save()
. 如果您对OOP joinWith()
那么可以使用Propel- http: joinWith()
它处理所有逻辑并为您提供诸如joinWith()
和getThis()
, setThat()
, save()
。
It appears Propel does break queries apart, so that it can deliver several objects that can be saved individually. 看来Propel确实将查询分开了,因此它可以提供几个可以单独保存的对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.