检索mysql中最后更新的列 [英] retrieve last updated column in mysql

查看:144
本文介绍了检索mysql中最后更新的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下的MySQL查询(使用Zend_Db):

I have a MySQL query that goes as follows (using Zend_Db):

 $sql = $handle->quoteInto("UPDATE board SET rank=rank+1 WHERE post_id=?", $postid);
 $handle->query($sql);

(等级不是自动递增的PK). 我现在想在不执行另一个查询的情况下检索rank的值. 我已经尝试过$handle->lastInsertId();,但是它似乎没有用,因为我没有使用MySQL的自然自动递增方法(我不能-rank是帖子的等级.我使用++或- -)

(Rank isn't an auto-incrementing PK). I would like to now retrieve the value of rank without preforming another query. I've tried $handle->lastInsertId(); but it doesn't seem to work , since I didn't use MySQL's natural auto-incrementing method (I can't - rank is the rank of a post. I either ++ or -- it.)

有什么方法可以执行另一个查询?一个函数将返回上次更改的值?

Any way to do this with preforming another query? A function that will return the last changed value?

推荐答案

我不认为这是可能的-您只需要执行SELECT.

I don't believe this is possible - you'll just have to do a SELECT.

这篇关于检索mysql中最后更新的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆