Questions about returned objects

Source: Internet
Author: User
Questions about the returned objects in the query // The Object class PHPcodeclassNewes {// varadvertisingid; // varadcontent; privateintadvertisingid; privateSt
// Entity class
PHP code
   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;        }       }

Solution
PHP code
  $sql="select * from newes where advertisingid =1";$abc =mysql_query($sql);/**while($num =mysql_fetch_array($abc)){    $num}*/

Q: How can I return an object class?
For example, Newes $ newes = new Newes ();
$ Newes = mysql_query ($ SQL); // Is this an object class returned?
Super beginner confused... please help me explain. thank you.

------ Solution --------------------
What is the relationship between the two codes ??
First returns the object class
The second mysql_query returns the result set of the resource type.
------ Solution --------------------
Such as: private int advertisingid; changed to private $ advertisingid;

Your set is the definition method in java.
------ Solution --------------------
Mysql_fetch_row ()
Mysql_fetch_array ()
Mysql_fetch_assoc ()

For details about the differences, refer to Google.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.