Your IP : 216.73.216.48
<?php
class Quizes {
private $_dbAdapter;
private $_table;
public function __construct() {
$this->_dbAdapter = new MySQL();
$this->_table = TABLE_PREFIX . 'quizes';
}
public function addQuiz($subjectID, $title) {
$insert = $this->_dbAdapter->runQuery('INSERT INTO ' . $this->_table . '
(subject,title,date_added)
VALUES ("' . $subjectID . '", "' . $title . '", "' . time() . '")');
return $this->_dbAdapter->getLastInsertedID();
}
public function getQuizes($whereClause = '') {
if ($whereClause != '') {
$select = $this->_dbAdapter->runQuery('SELECT * FROM ' . $this->_table . '
WHERE ' . $whereClause);
} else {
$select = $this->_dbAdapter->runQuery('SELECT * FROM ' . $this->_table);
}
if ($this->_dbAdapter->countRows($select) > 0) {
while ($row = $this->_dbAdapter->fetchRows($select)) {
$data[] = $row;
}
return $data;
}
}
public function getQuiz($whereClause = '') {
if ($whereClause != '') {
$select = $this->_dbAdapter->runQuery('SELECT * FROM ' . $this->_table . '
WHERE ' . $whereClause);
}
if ($this->_dbAdapter->countRows($select) > 0) {
return $this->_dbAdapter->fetchRows($select);
}
}
}