简体   繁体   English

如何在MultiQuery MySQLi和PHP中识别特定的select语句

[英]How to identify a particular select statement in multiquery mysqli and php

I have created a stored procedure which contains multiple select query in PHP. 我创建了一个存储过程,其中包含PHP中的多个select查询。 I am using mysqli_multi_query to call the procedure and I'm using mysqli_store_result to store the result of select query. 我正在使用mysqli_multi_query调用该过程,并且正在使用mysqli_store_result存储选择查询的结果。

Question is that I want to identify the select query, which select query is getting the result, I want to tag it uniquely 问题是我想识别选择查询,哪个选择查询正在获取结果,我想对其进行唯一标记

You can add an extra column to each query, like this: 您可以为每个查询添加一个额外的列,如下所示:

select 'query_tag_1' as tag, ...
from your_table;

select 'query_tag_2' as tag, ...
from your_table;

select 'query_tag_3' as tag, ...
from your_table;

You can check the value of tag column from PHP. 您可以从PHP检查tag列的值。

Update : Another way would be to rename a column (the first for example): 更新 :另一种方法是重命名列(例如第一个):

select id as id_tag1, ...
from your_table;

select id as id_tag2, ...
from your_table;

select id as id_tag3, ...
from your_table;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM