note 90807 added to function.mysql-query

From: Date: Mon, 11 May 2009 13:18:04 +0000
Subject: note 90807 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-154442@lists.php.net to get a copy of this message
Here are a few classes that I have wrote to make accessing the database and retrieving data really simple. I have three classes that are broken into several notes on this site as they are quite big. I also have the usage on the last note: MySQL.php : <?php include("MyData.php"); include("MyDB.php"); class MySQL { private $myDB; private $rawData; public function MySQL ($server, $database, $username, $password) { $this->setDB($server, $database, $username, $password); } public function execSQL ($sql, &$results) { if($this->myDB->openConnection()) { $this->rawData = $this->myDB->accessDB($sql); $this->myDB->closeConnection(); $results = $this->compileResults(); } else { return(0); } return(1); } private function compileResults () { $rowCount = mysql_num_rows($this->rawData); $fieldCount = mysql_num_fields($this->rawData); $myData = new MyData(); for($Row=0; $Row<$rowCount; $Row++) { for($Field=0; $Field<$fieldCount; $Field++) { $fieldInfo = mysql_fetch_field($this->rawData, $Field); $fieldName = $fieldInfo->name; $data = mysql_result($this->rawData, $Row, $fieldName); $myData->addDataToList($Row, $fieldName, $data); } } return($myData); } private function setDB ($server, $database, $username, $password) { $this->myDB = new MyDB($server, $database, $username, $password); } public function getDB () { return($this->myDB); } } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 170.252.64.1 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- https://master.php.net/note/edit/90807 Del: integrated -- https://master.php.net/note/delete/90807/integrated Del: useless -- https://master.php.net/note/delete/90807/useless Del: bad code -- https://master.php.net/note/delete/90807/bad+code Del: spam -- https://master.php.net/note/delete/90807/spam Del: non-english -- https://master.php.net/note/delete/90807/non-english Del: in docs -- https://master.php.net/note/delete/90807/in+docs Del: other reasons-- https://master.php.net/note/delete/90807 Reject -- https://master.php.net/note/reject/90807 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154442) next »