首頁  >  文章  >  後端開發  >  关于查询返回实体的有关问题

关于查询返回实体的有关问题

WBOY
WBOY原創
2016-06-13 10:20:19783瀏覽

关于查询返回实体的问题
//实体类

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> class Newes   {   //var advertisingid;   //var adcontent;             private int advertisingid;        private String adcontent;        private String texttitle;        private String prclink;        private String time;        private String urllink;        private int newtype;        private String newlaiyuan;        public function getId()        {            return $this->advertisingid;        }        public function setId($advertisingid)        {            $this->advertisingid=$advertisingid;            return $this;        }        public function getAdcontent()        {            return $this->adcontent;        }        public function setAdcontent($adcontent)        {            $this->adcontent=$adcontent;            return $this;        }        public function getTexttitle()        {            return $this->texttitle;        }        public function setTexttitle($texttitle)        {            $this->texttitle=$texttitle;            return $this;        }       }

处理方法
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$sql="select * from newes where advertisingid =1";$abc =mysql_query($sql);/**while($num =mysql_fetch_array($abc)){    $num}*/

问:就是用什么方法返回一个实体类
比如 Newes $newes = new Newes();
$newes =mysql_query($sql); //这样子就是返回一个实体类么?
超级新手迷糊中····请帮忙解释一下 谢谢

------解决方案--------------------
两段代码之间有神马关系??
第一个返回实体类
第二个mysql_query返回resource类型的结果集
------解决方案--------------------
形如: private int advertisingid; 改为 private $advertisingid;

你那套是java里面的定义方法吧。
------解决方案--------------------
mysql_fetch_row()
mysql_fetch_array()
mysql_fetch_assoc()

具体区别,请谷歌查。
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn