cgm225 Posted July 12, 2008 Share Posted July 12, 2008 I just completed a notes/blog class for my website and everything works fine; however I still wanted to get some feedback. Are there any things I could be doing better? <?php class Notes { //Declaring variables private $connection; private $id; private $data = array(); //Sets MySQLi object public function __construct(mysqli $connection) { $this->connection = $connection; } /* Creates a two dimensional array in which entry id numbers are stored in * the first dimension, and then for each id number, a second array (i.e. * the second dimension) is assigned, which contains all the field values * for that particular entry. */ public function findEntries() { $query = 'SELECT id, title, note, date, timestamp FROM notes ORDER BY id DESC'; $statement = $this->connection->prepare($query); $statement->bind_result($id, $title, $note, $date, $timestamp); $statement->execute(); while($statement->fetch()) { $this->data[$id] = array( 'id' => $id, 'title' => $title, 'date' => $date, 'note' => $note, 'timestamp' => $timestamp ); } $statement->close(); } //Returns the data array public function getData() { if (!empty($this->data)){ return $this->data; } else { return false; } } //Returns the number of items in the data array public function getDataCount() { if (!empty($this->data)){ return count($this->data); } else { return false; } } //Returns a particular range of the data in the data array public function getSlicedData($offset = 0, $length = 10000) { if (!empty($this->data)){ return array_slice(array_values($this->data), $offset, $length); } else { return false; } } } ?> Link to comment Share on other sites More sharing options...
cgm225 Posted July 13, 2008 Author Share Posted July 13, 2008 bump Link to comment Share on other sites More sharing options...
cgm225 Posted July 14, 2008 Author Share Posted July 14, 2008 bump Link to comment Share on other sites More sharing options...
imdead Posted July 14, 2008 Share Posted July 14, 2008 Looks Pretty Good To Me Mate Link to comment Share on other sites More sharing options...
Recommended Posts