if (isset($_POST['agree'])) { // 判断 POST 请求中的 cid 是否是本篇文章的 cid if ($_POST['agree'] == $this->cid) { // 调用点赞函数,传入文章的 cid,然后通过 exit 输出点赞数量 exit(agree($this->cid)); } // 如果点赞的文章 cid 不是本篇文章的 cid 就输出 error 不再往下执行 exit('error'); }

knexjs操作数据库

knexjs操作数据库

Knex.js is a "batteries included" SQL query builder for Postgres, MSSQL, MySQL, MariaDB, SQLite3, Oracle, and Amazon Redshift designed to be flexible, portable, and fun to use. It features both traditional node style callbacks as well as a promise interface for cleaner async flow control, a stream interface, full featured query and schema builders, transaction support (with savepoints), connection pooling and standardized responses between different query clients and dialects.
没什么要说的,就是操作数据库

mysql('mpArticle').orderBy('id','desc').limit(1)
//查找最近一条记录
mysql('mpArticle').insert(postdata)
//插入数据库
mysql('user').where('wx_openid', user.wx_openid).count('wx_openid as i')
//判断数据是否存在
mysql('usefulTel').select('company_pic')
//查询筛选
mysql('user').update('user_phone', movecar.user_phone).where('wx_openid', openid)
//更新数据库
来都来了,留个言吧🙂