數(shù)據(jù)庫(kù)字段有種類(lèi)型叫blob,就是專(zhuān)門(mén)用來(lái)存放二進(jìn)制數(shù)據(jù)的。但是一般文件類(lèi)的在數(shù)據(jù)庫(kù)都是只存?zhèn)€路徑而已,不會(huì)真的放到數(shù)據(jù)庫(kù)里的,那樣不方便管理。
創(chuàng)新互聯(lián)公司是專(zhuān)業(yè)的貴定網(wǎng)站建設(shè)公司,貴定接單;提供網(wǎng)站建設(shè)、做網(wǎng)站,網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專(zhuān)業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行貴定網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專(zhuān)業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專(zhuān)業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
PHP隨便你用什么框架都不是問(wèn)題,重點(diǎn)是玩的熟悉了后,PHPER自己做出類(lèi)似YII,CI的框架都不是問(wèn)題,而且現(xiàn)在成熟框架來(lái)說(shuō),也有很多缺點(diǎn)比如 ZEND FRAMEWORK,走的是MVC套路,但是實(shí)際上低成本的框架不一定是這個(gè)結(jié)構(gòu),而是后BS時(shí)代的近似于CS結(jié)構(gòu)的那種通信方式,代碼越少,開(kāi)發(fā)周期就會(huì)變短。YII的問(wèn)題是過(guò)度封裝,仔細(xì)閱讀代碼,就會(huì)發(fā)現(xiàn),這個(gè)過(guò)度封裝,導(dǎo)致代碼繁瑣CI的主要問(wèn)題是數(shù)據(jù)庫(kù)支持,以后隨著NOSQL類(lèi)數(shù)據(jù)庫(kù)的大型其道,CI那種數(shù)據(jù)庫(kù)查詢(xún)的封裝方式,會(huì)導(dǎo)致很多功能無(wú)法通過(guò)其內(nèi)框架內(nèi)的查詢(xún)封裝解決,比如NOSQL中的立體數(shù)據(jù),動(dòng)態(tài)增減字段,把數(shù)據(jù)當(dāng)成隊(duì)列做PUSH和PULL的操作,都無(wú)法正常使用,犧牲了一些高級(jí)特性我一直都用自己書(shū)寫(xiě)的框架來(lái)構(gòu)建項(xiàng)目,隨著目前項(xiàng)目結(jié)構(gòu)和趨勢(shì)的變化,有一部分遷移到了NODE.JS,PHP不再是最嘉選擇,如果還有不明白的話(huà),你也可以去后盾人平臺(tái)看看php基礎(chǔ)教學(xué)視頻看看,也是不錯(cuò)的選擇,希望能幫到你,給個(gè)采納吧謝謝((?(//?Д/?/)?))
通常的做法都是從數(shù)據(jù)庫(kù)里取出數(shù)據(jù),然后生成xml或者json的格式,傳給播放器就可以了。我在做視頻播放的時(shí)候就是采用的這種方式。現(xiàn)在js和as3是可以交互的。
復(fù)制代碼
代碼如下:
?php
/*
MYSQL
數(shù)據(jù)庫(kù)訪問(wèn)封裝類(lèi)
MYSQL
數(shù)據(jù)訪問(wèn)方式,php4支持以mysql_開(kāi)頭的過(guò)程訪問(wèn)方式,php5開(kāi)始支持以mysqli_開(kāi)頭的過(guò)程和mysqli面向?qū)ο?/p>
訪問(wèn)方式,本封裝類(lèi)以mysql_封裝
數(shù)據(jù)訪問(wèn)的一般流程:
1,連接數(shù)據(jù)庫(kù)
mysql_connect
or
mysql_pconnect
2,選擇數(shù)據(jù)庫(kù)
mysql_select_db
3,執(zhí)行SQL查詢(xún)
mysql_query
4,處理返回的數(shù)據(jù)
mysql_fetch_array
mysql_num_rows
mysql_fetch_assoc
mysql_fetch_row
etc
*/
class
db_mysql
{
var
$querynum
=
;
//當(dāng)前頁(yè)面進(jìn)程查詢(xún)數(shù)據(jù)庫(kù)的次數(shù)
var
$dblink
;
//數(shù)據(jù)庫(kù)連接資源
//鏈接數(shù)據(jù)庫(kù)
function
connect($dbhost,$dbuser,$dbpw,$dbname='',$dbcharset='utf-8',$pconnect=0
,
$halt=true)
{
$func
=
empty($pconnect)
?
'mysql_connect'
:
'mysql_pconnect'
;
$this-dblink
=
@$func($dbhost,$dbuser,$dbpw)
;
if
($halt
!$this-dblink)
{
$this-halt("無(wú)法鏈接數(shù)據(jù)庫(kù)!");
}
//設(shè)置查詢(xún)字符集
mysql_query("SET
character_set_connection={$dbcharset},character_set_results={$dbcharset},character_set_client=binary",$this-dblink)
;
//選擇數(shù)據(jù)庫(kù)
$dbname
@mysql_select_db($dbname,$this-dblink)
;
}
//選擇數(shù)據(jù)庫(kù)
function
select_db($dbname)
{
return
mysql_select_db($dbname,$this-dblink);
}
//執(zhí)行SQL查詢(xún)
function
query($sql)
{
$this-querynum++
;
return
mysql_query($sql,$this-dblink)
;
}
//返回最近一次與連接句柄關(guān)聯(lián)的INSERT,UPDATE
或DELETE
查詢(xún)所影響的記錄行數(shù)
function
affected_rows()
{
return
mysql_affected_rows($this-dblink)
;
}
//取得結(jié)果集中行的數(shù)目,只對(duì)select查詢(xún)的結(jié)果集有效
function
num_rows($result)
{
return
mysql_num_rows($result)
;
}
//獲得單格的查詢(xún)結(jié)果
function
result($result,$row=0)
{
return
mysql_result($result,$row)
;
}
//取得上一步
INSERT
操作產(chǎn)生的
ID,只對(duì)表有AUTO_INCREMENT
ID的操作有效
function
insert_id()
{
return
($id
=
mysql_insert_id($this-dblink))
=
?
$id
:
$this-result($this-query("SELECT
last_insert_id()"),
0);
}
//從結(jié)果集提取當(dāng)前行,以數(shù)字為key表示的關(guān)聯(lián)數(shù)組形式返回
function
fetch_row($result)
{
return
mysql_fetch_row($result)
;
}
//從結(jié)果集提取當(dāng)前行,以字段名為key表示的關(guān)聯(lián)數(shù)組形式返回
function
fetch_assoc($result)
{
return
mysql_fetch_assoc($result);
}
//從結(jié)果集提取當(dāng)前行,以字段名和數(shù)字為key表示的關(guān)聯(lián)數(shù)組形式返回
function
fetch_array($result)
{
return
mysql_fetch_array($result);
}
//關(guān)閉鏈接
function
close()
{
return
mysql_close($this-dblink)
;
}
//輸出簡(jiǎn)單的錯(cuò)誤html提示信息并終止程序
function
halt($msg)
{
$message
=
"html\nhead\n"
;
$message
.=
"meta
content='text/html;charset=gb2312'\n"
;
$message
.=
"/head\n"
;
$message
.=
"body\n"
;
$message
.=
"數(shù)據(jù)庫(kù)出錯(cuò):".htmlspecialchars($msg)."\n"
;
$message
.=
"/body\n"
;
$message
.=
"/html"
;
echo
$message
;
exit
;
}
}
?
?php
class MySQL{
private $host; //服務(wù)器地址
private $name; //登錄賬號(hào)
private $pwd; //登錄密碼
private $dBase; //數(shù)據(jù)庫(kù)名稱(chēng)
private $conn; //數(shù)據(jù)庫(kù)鏈接資源
private $result; //結(jié)果集
private $msg; //返回結(jié)果
private $fields; //返回字段
private $fieldsNum; //返回字段數(shù)
private $rowsNum; //返回結(jié)果數(shù)
private $rowsRst; //返回單條記錄的字段數(shù)組
private $filesArray = array(); //返回字段數(shù)組
private $rowsArray = array(); //返回結(jié)果數(shù)組
private $charset='utf8'; //設(shè)置操作的字符集
private $query_count=0; //查詢(xún)結(jié)果次數(shù)
static private $_instance; //存儲(chǔ)對(duì)象
//初始化類(lèi)
private function __construct($host='',$name='',$pwd='',$dBase=''){
if($host != '') $this-host = $host;
if($name != '') $this-name = $name;
if($pwd != '') $this-pwd = $pwd;
if($dBase != '') $this-dBase = $dBase;
$this-init_conn();
}
//防止被克隆
private function __clone(){}
public static function getInstance($host='',$name='',$pwd='',$dBase=''){
if(FALSE == (self::$_instance instanceof self)){
self::$_instance = new self($host,$name,$pwd,$dBase);
}
return self::$_instance;
}
public function __set($name,$value){
$this-$name=$value;
}
public function __get($name){
return $this-$name;
}
//鏈接數(shù)據(jù)庫(kù)
function init_conn(){
$this-conn=@mysql_connect($this-host,$this-name,$this-pwd) or die('connect db fail !');
@mysql_select_db($this-dBase,$this-conn) or die('select db fail !');
mysql_query("set names ".$this-charset);
}
//查詢(xún)結(jié)果
function mysql_query_rst($sql){
if($this-conn == '') $this-init_conn();
$this-result = @mysql_query($sql,$this-conn);
$this-query_count++;
}
//取得字段數(shù)
function getFieldsNum($sql){
$this-mysql_query_rst($sql);
$this-fieldsNum = @mysql_num_fields($this-result);
}
//取得查詢(xún)結(jié)果數(shù)
function getRowsNum($sql){
$this-mysql_query_rst($sql);
if(mysql_errno() == 0){
return @mysql_num_rows($this-result);
}else{
return '';
}
}
//取得記錄數(shù)組(單條記錄)
function getRowsRst($sql,$type=MYSQL_BOTH){
$this-mysql_query_rst($sql);
if(empty($this-result)) return '';
if(mysql_error() == 0){
$this-rowsRst = mysql_fetch_array($this-result,$type);
return $this-rowsRst;
}else{
return '';
}
}
//取得記錄數(shù)組(多條記錄)
function getRowsArray($sql,$type=MYSQL_BOTH){
!empty($this-rowsArray) ? $this-rowsArray=array() : '';
$this-mysql_query_rst($sql);
if(mysql_errno() == 0){
while($row = mysql_fetch_array($this-result,$type)) {
$this-rowsArray[] = $row;
}
return $this-rowsArray;
}else{
return '';
}
}
//更新、刪除、添加記錄數(shù)
function uidRst($sql){
if($this-conn == ''){
$this-init_conn();
}
@mysql_query($sql);
$this-rowsNum = @mysql_affected_rows();
if(mysql_errno() == 0){
return $this-rowsNum;
}else{
return '';
}
}
//返回最近插入的一條數(shù)據(jù)庫(kù)的id值
function returnRstId($sql){
if($this-conn == ''){
$this-init_conn();
}
@mysql_query($sql);
if(mysql_errno() == 0){
return mysql_insert_id();
}else{
return '';
}
}
//獲取對(duì)應(yīng)的字段值
function getFields($sql,$fields){
$this-mysql_query_rst($sql);
if(mysql_errno() == 0){
if(mysql_num_rows($this-result) 0){
$tmpfld = @mysql_fetch_row($this-result);
$this-fields = $tmpfld[$fields];
}
return $this-fields;
}else{
return '';
}
}
//錯(cuò)誤信息
function msg_error(){
if(mysql_errno() != 0) {
$this-msg = mysql_error();
}
return $this-msg;
}
//釋放結(jié)果集
function close_rst(){
mysql_free_result($this-result);
$this-msg = '';
$this-fieldsNum = 0;
$this-rowsNum = 0;
$this-filesArray = '';
$this-rowsArray = '';
}
//關(guān)閉數(shù)據(jù)庫(kù)
function close_conn(){
$this-close_rst();
mysql_close($this-conn);
$this-conn = '';
}
//取得數(shù)據(jù)庫(kù)版本
function db_version() {
return mysql_get_server_info();
}
}
鏈接:
提取碼:?c9fj
《PHP自學(xué)視頻教程》???分3篇共22章,其中,第1篇為入門(mén)篇,主要包括了解PHP、PHP開(kāi)發(fā)環(huán)境搭建、PHP開(kāi)發(fā)基礎(chǔ)、PHP流程控制語(yǔ)句、函數(shù)、字符串操作、正則表達(dá)式、PHP數(shù)組、PHP與Web頁(yè)面交互、日期和時(shí)間等內(nèi)容;第2篇為提高篇,主要包括MySQL數(shù)據(jù)庫(kù)設(shè)計(jì)、PHP操作MySQL數(shù)據(jù)庫(kù)、Cookie和Session、圖形圖像處理技術(shù)、文件和目錄處理技術(shù)、面向?qū)ο蟆DO數(shù)據(jù)庫(kù)抽象層、程序調(diào)試與錯(cuò)誤處理、Ajax技術(shù)、Smarty模板技術(shù)等內(nèi)容;第3篇為實(shí)戰(zhàn)篇,主要包括明日企業(yè)網(wǎng)、應(yīng)用Smarty模板開(kāi)發(fā)電子商務(wù)平臺(tái)等兩個(gè)實(shí)戰(zhàn)項(xiàng)目。 ?
網(wǎng)頁(yè)題目:php數(shù)據(jù)庫(kù)封裝視頻 PHP封裝
分享URL:http://m.kartarina.com/article26/hgjjcg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、自適應(yīng)網(wǎng)站、微信公眾號(hào)、定制網(wǎng)站、電子商務(wù)、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)