轻言放弃之博客004

函数封装
// mysql.php

 $v) {
                $sql .= $k . "='" .$v . "',";
            }
            $sql = rtrim($sql, ',') . " where " . $where;// 去掉最后一个多余的逗号
            // echo $sql;
            return mQuery($sql);
        }
    }

    $data = array('title' => '今天的空气', 'content' => '空气质量堪忧', 'pubtime' => 123456, 'author' => 'Aaayang');
    // insert into art(title, content, pubtime, author) values ('今天的空气', '空气质量堪忧', '123456', 'Aaayang');
    // update art set title='今天的空气', content='空气质量堪忧', pubtime='123456', author='Aaayang' where art_id=1;
    // echo mExec('art', $data, 'update', "art_id=1");

    /**
     * 取得上一步insert操作产生的主键ID
     */
    function getLastId() {
        return mysql_insert_id(mConn());
    }
    
 ?>
连接数据库

你可能感兴趣的:(轻言放弃之博客004)