Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 46d7fad

Browse files
添加 mysql 案例blog
1 parent dd80f21 commit 46d7fad

File tree

9 files changed

+337
-151
lines changed

9 files changed

+337
-151
lines changed

‎.idea/workspace.xml‎

Lines changed: 222 additions & 151 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎php-mysql/blog/add_new.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年10月31日
6+
* Time: 23:04
7+
*/
8+
//添加新blog

‎php-mysql/blog/class/conn.php‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年11月1日
6+
* Time: 21:44
7+
*/
8+
//连接服务器的类
9+
class ConnDB{
10+
var $host; //主机
11+
var $user; //用户名称
12+
var $pwd; //登录密码
13+
var $dbname; //数据库名字
14+
var $conn;
15+
function conn_db($host,$user,$pwd,$dbname){ //构造方法,为成员变量赋值
16+
$this->host = $host;
17+
$this->user = $user;
18+
$this->pwd = $pwd;
19+
$this->dbname = $dbname;
20+
}
21+
function GetConn(){ // 连接数据库
22+
$this->conn = mysqli_connect($this->host,$this->user,$this->pwd) or die ("数据库服务器连接错误").mysqli_error();
23+
mysqli_select_db($this->conn,$this->dbname) or die("数据库选择错误").mysqli_error($this->conn);
24+
mysqli_query($this->conn,"set names 'utf-8'");//设置数据库的编码格式
25+
return $this->conn; //返回连接对象
26+
}
27+
function CloseConn9(){ //定义关闭数据库的方法
28+
mysqli_close($this->conn);
29+
}
30+
}

‎php-mysql/blog/class/system.php‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年11月1日
6+
* Time: 22:02
7+
*/
8+
require 'conn.php';
9+
//取回数据库中网站的基本信息
10+
class SystemInfo{
11+
var $site_name; //站点名称
12+
var $site_owner; //站点作者
13+
function get_info(){
14+
$sys_conn = new ConnDB();
15+
$sys_conn->conn_db('localhost','root','','system_config');
16+
$conn = $sys_conn->GetConn();
17+
$this->site_name = mysqli_query($conn,"select blog_title from system_config");
18+
$this->site_owner = mysqli_query($conn,"select blog_hoster from system_config");
19+
20+
}
21+
function SetInfo(){
22+
if($this->site_name == ''){
23+
$this->site_name = 'site_name';
24+
}
25+
26+
if($this->site_name == ''){
27+
$this->site_owner = 'site_hoster';
28+
}
29+
define('SITE_NAME',$this->site_name,TRUE);
30+
define('SITE_OWNER',$this->site_owner,TRUE);
31+
}
32+
}
33+
$system_info = new SystemInfo();
34+
$system_info->get_info();
35+
$system_info->get_info();

‎php-mysql/blog/dashboard.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年10月31日
6+
* Time: 23:02
7+
*/
8+
//后台主页,展示blog列表,提供编辑、管理入口(编辑、删除、添加)

‎php-mysql/blog/edit.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年10月31日
6+
* Time: 23:02
7+
*/
8+
//内容编辑页面

‎php-mysql/blog/index.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年10月31日
6+
* Time: 23:01
7+
*/
8+
//主页
9+
echo SITE_NAME;
10+
echo SITE_OWNER;

‎php-mysql/blog/login.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年10月31日
6+
* Time: 23:02
7+
*/
8+
//登录页面

‎php-mysql/blog/register.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年10月31日
6+
* Time: 23:02
7+
*/
8+
//注册页面

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /