标签:func html add elf 取值 person foreach 标题 资源
建完数据库,下面就是操作数据库啦
程序的根源无非是增删改查
首先最基础的查询
public function obtainduo(){ header("content-type:text/html; charset=utf-8");//有的时候会乱码,所以定义一下格式 $conn = oci_connect ( ‘user‘, ‘pwd‘, "192.168.1.1/xbxxf", ‘UTF8‘);//连接信息 if (!$conn) { $this->var[‘personinfoTs‘] = ‘连接系统出错,请联系西贝小小凤‘; }else{ $sql = "select * from fund";//sql 语句 $stmt = oci_parse ( $conn, $sql );// 配置 Oracle 语句预备执行 oci_execute ( $stmt, OCI_DEFAULT );//执行SQL oci_fetch_all ( $stmt, $result, 0, - 1, OCI_FETCHSTATEMENT_BY_ROW ); oci_free_statement ( $stmt ); oci_close ( $conn ); //数组编码转换 foreach( $result as $v ) { $_result [] = $v; } return $_result; } }
新增
public function addfund($data){ $Oracle_conn = oci_connect ( ‘user‘, ‘pwd‘, "192.168.1.1/xbxxf", ‘UTF8‘); $query="insert into fund(name,desc) values (:name,:desc)"; $statement=oci_parse($Oracle_conn,$query); //===============设置绑定变量的取值(通过变量提供值)================ $name="文章标题"; $desc="简述爱的很骄傲和大伙房间哈佛好烦";
oci_bind_by_name($statement,":name",$name); oci_bind_by_name($statement,":desc",$desc); //执行语句,设置执行模式为自动提交 oci_execute($statement,OCI_COMMIT_ON_SUCCESS); //检查影响的行数 if(oci_num_rows){ $res=1; }else{ $res=0; } //释放资源 oci_free_statement($statement); oci_close($Oracle_conn); return $res; }
删除
public function delfundvalue($excel_id){ $Oracle_conn = oci_connect ( ‘user‘, ‘pwd‘, "192.168.1.1/xbxxf", ‘UTF8‘);//连接信息 $query="delete from fund where id =1"; //===============设置绑定变量的取值(通过变量提供值)================ $stmt = oci_parse ( $Oracle_conn, $query ); oci_execute ( $stmt, OCI_COMMIT_ON_SUCCESS ); //检查影响的行数 if(oci_num_rows){ $res=1; }else{ $res=0; } //释放资源 oci_free_statement($statement); oci_close($Oracle_conn); return $res; }
修改没做,等我过几天更新啊,最近太忙了,233333
PHP 操作oracle数据库,select,insert into ,delete等
标签:func html add elf 取值 person foreach 标题 资源
原文地址:https://www.cnblogs.com/xbxxf/p/11066091.html