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

WBOY
Release: 2016-06-13 10:20:19
Original
820 people have browsed it

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

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;        }       }
Copy after login

处理方法
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}*/
Copy after login

问:就是用什么方法返回一个实体类
比如 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()

具体区别,请谷歌查。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template