第一周学习知识点总结及感悟
2017-09-10 本文已影响0人
ve佐手
第一部分-知识点
1.git命令
- 把主分支项目拉取下来
git fetch
git merge origin/master
git diff //查看有没有冲突 - 上传分支
cd 文件夹名称
git add .
git commit -m 写说明这是干嘛的
git branch //这是创建分支
git checkout //这是切换分支
git push origin fengxiaobin:fengxiaobin 把分支推送到远程
git status 查看状态
2. 使用PDO连接数据库实现增删改查功能
- 连接到数据库
function db(){
try {
$pdo = new PDO(mysql:host=" "; dbname=" ", username="root", passwd=" ");
return $pdo;}catch ($e) {
die("fail to connect mysql" .$e ->getMessage());
}
}
- 增加
function add($data) {
$pdo = db();
$sql = "INSERT INTO photo (name,path) VALUES(?,?)";
$std = $pdo -> prepare($sql);
$res = $std -> execute($data);
return $res;
}
- 删除
function delete($id) {
$pdo = db();
$sql = "DELETE from photo where id = ?";
$std = $pdo -> prepare($sql);
$res = $std -> execute([$id]);
return $res;
}
- 修改
function update($data){
$pdo = db();
$sql = "UPDATE photo set name = ?,path = ? where id = ?";
$std = $pdo -> prepare($sql);
$res = $std ->execute($data);
return $res;
}
- 查询
function select() {
$pdo = db();
$sql = "select * from photo";
$std = $pdo -> query($sql);
$res = $std -> fetchALL();
return $res;
}
- 查询id
function selectOne($id) {
$pdo = db();
$sql = "select * from photo where id = $id";
$std = $pdo -> query($sql);
$res = $std -> fetch();
return $res;
}
- 全局配置
define('DB_ADDRESS','127.0.0.1');
define('DB_NAME','sys-photo');
define('DB_USER','root');
define('DB_PASS','123456');