php面向对象怎么那么难,

shao_jingna 2010-11-03 08:10:48
有没有高手帮忙指教一下啊,都不知道怎么学了,或者推荐几本书看看也行
...全文
400 30 打赏 收藏 转发到动态 举报
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
shao_jingna 2010-11-09
  • 打赏
  • 举报
回复
[Quote=引用 29 楼 networkwx 的回复:]
估计你比较怕羞,面向着对象就搞不定了?那面向着墙吧。
[/Quote]
晕,
happy664618843 2010-11-08
  • 打赏
  • 举报
回复
networkwx 2010-11-08
  • 打赏
  • 举报
回复
估计你比较怕羞,面向着对象就搞不定了?那面向着墙吧。
shao_jingna 2010-11-07
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 showerxp 的回复:]
PHP code

<?php
include_once("incClass.php");

class DAO{
protected $conn;
protected $table;
public $errors;
function __construct($table){
$this->conn = getConn();
……
[/Quote]高手啊,请指教
k1060220963 2010-11-05
  • 打赏
  • 举报
回复
面向对象不难啊,你多看看书。
txzsp 2010-11-05
  • 打赏
  • 举报
回复
18层的那位写的不就是咯。
showerXP 2010-11-05
  • 打赏
  • 举报
回复
上面关于数据库crud的DAO类。每一张表继承DAO就可以实现数据库的crud。
showerXP 2010-11-05
  • 打赏
  • 举报
回复

<?php
include_once("incClass.php");

class DAO{
protected $conn;
protected $table;
public $errors;
function __construct($table){
$this->conn = getConn();
$this->table = $table;
$this->errors = false;
}
function get($Id){
$rs = $this->conn->execute("select * from $this->table where id =$Id");
return $rs->GetArray();
}
function save($fields,$Id = false){
if (!$Id) {
//insert
$rs=$this->conn->Execute("SELECT * FROM $this->table");
$insertSQL = $this->conn->GetInsertSQL($rs, $fields);
$this->conn->Execute($insertSQL);
if ($this->conn->ErrorMsg()) $this->errors = $this->conn->ErrorMsg();
}
else {
//update
$rs=$this->conn->Execute("SELECT * FROM $this->table where id=$Id");
$updateSQL = $this->conn->GetUpdateSQL($rs, $fields);
$this->conn->Execute($updateSQL);
//if ($this->conn->ErrorMsg()) $this->errors= $this->conn->ErrorMsg();
}
}
function delete($Id){
$sql="delete from $this->table where id=$Id";
$this->conn->execute($sql);
if ($this->conn->ErrorMsg()) $this->errors= $this->conn->ErrorMsg();
}
}

class IdbDao extends DAO {
function __construct(){
parent::__construct("idb");
}
function delete($id){
$sql = "delete from amendsdetaildb where Iid=$id";
$this->conn->execute($sql);
parent::delete($id);
}

}

class AdmendsDetailDbDAO extends DAO {
function __construct(){
parent::__construct("amendsdetaildb");
}
function getDetail($Iid){
$rs = $this->conn->execute("select * from $this->table where Iid =$Iid");
return $rs->GetArray();
}
}

class ObjectDbDAO extends DAO {
function __construct(){
parent::__construct("objectdb");
}
}

?>
liuahuilele 2010-11-05
  • 打赏
  • 举报
回复
先学习java 再学php 这样蛮容易的 呵呵
zhjiashan123 2010-11-05
  • 打赏
  • 举报
回复
靠积累啊。。
weizhao029 2010-11-05
  • 打赏
  • 举报
回复
刚刚起步都挺难的
君望永远 2010-11-05
  • 打赏
  • 举报
回复
和Java C#差不多的 自己看看 兄弟连的视频也不错~ 实际项目开发一般只要看懂别人的 目前自己写还是面向过程~
LORNPUNISHR 2010-11-05
  • 打赏
  • 举报
回复
刚刚起步都挺难的
在-云端 2010-11-05
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 amani11 的回复:]

应该了解OO思想


用你追女孩子那股不要脸的劲头,很快就入门了,而且,到手后,不会跟女朋友一样是不是耍脾气


不过,你编写php不一定非得面向对象
[/Quote]

莫非你已经得手了!!
amani11 2010-11-04
  • 打赏
  • 举报
回复
应该了解OO思想


用你追女孩子那股不要脸的劲头,很快就入门了,而且,到手后,不会跟女朋友一样是不是耍脾气


不过,你编写php不一定非得面向对象
wl850620 2010-11-04
  • 打赏
  • 举报
回复
xiexiaokang 2010-11-04
  • 打赏
  • 举报
回复
用你追女孩子那股不要脸的劲头,很快就入门了,而且,到手后,不会跟女朋友一样是不是耍脾气
yourfathers 2010-11-04
  • 打赏
  • 举报
回复
老了,不是玩儿程序的人了!
xiaocai520 2010-11-04
  • 打赏
  • 举报
回复
面对对象没你说的那么夸张,就是设定一个对象是猪
属性:重量,颜色
转为变量$wight
行动:走路
function onload(){
//行走的操作
}
最后就是把这个丢到一个 class pig() 这个类里面
然后 $p = new pig();
最后$p->onload() 调用方法
其实就是针对你以前随便调用函数而言,这里是将函数封装到类里面,通过类去调用而已。
shao_jingna 2010-11-04
  • 打赏
  • 举报
回复
我都是看教程的,自己没怎么编,
加载更多回复(9)

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧