public function testLoadThrowsExceptionIfNothingSetExplicitlyAndDoesntExistInDatabase() { $record = new Record(array('id' => 4, 'name' => 'test'), $this->dao, false); $this->dao->expects($this->any())->method('getAttributes')->will($this->returnValue(array('id' => Dao::INT, 'name' => Dao::STRING))); $this->setExpectedException('RecordException', 'You tried to load a Record which had not attributes set.'); $record->load(); }
public function saveAndLoad(Record $record) { $record->save(); $loadedRecord = Record::load($record->getTableName(), $record->getId(), get_class($record)); foreach ($record->getAttributes() as $key => $value) { $this->assertEquals($value, $loadedRecord->{$key}); } $record->delete(); }
public function load($iGenreID) { $oCon = new Connection(); $sSQL = "SELECT GenreID, GenreName, DisplayOrder \n\t\t\tFROM tbgenres \n\t\t\tWHERE GenreID = " . $iGenreID; $oResultSet = $oCon->query($sSQL); $aRow = $oCon->fetchArray($oResultSet); $this->iGenreID = $aRow['GenreID']; $this->sGenreName = $aRow['GenreName']; $this->iDisplayOrder = $aRow['DisplayOrder']; $sSQL = "SELECT RecordID\n\t\t\tFROM tbrecords \n\t\t\tWHERE GenreID = " . $iGenreID; $oResultSet = $oCon->query($sSQL); while ($aRow = $oCon->fetchArray($oResultSet)) { $iRecordID = $aRow["RecordID"]; $oRecord = new Record(); $oRecord->load($iRecordID); $this->aRecords[] = $oRecord; } $oCon->close(); }
public static function renderCart($oCart) { $sHTML = '<table class="cart">'; $sHTML .= ' <tr> <th>Artist</th> <th>Title</th> <th>Price</th> <th>RecordID</th> <th>Quantity</th> </tr>'; $aContents = $oCart->contents; // echo "<pre>"; // print_r($aContents); // echo "</pre>"; foreach ($aContents as $iRecordID => $iQuantity) { $oRecord = new Record(); $oRecord->load($iRecordID); $sHTML .= ' <tr> <td>' . $oRecord->Artist . '</td> <td>' . $oRecord->Title . '</td> <td>' . $oRecord->Price . '</td> <td>' . $oRecord->RecordID . '</td> <td>' . $iQuantity . '</td> <td class="remove"><a href="removeFromCart.php?RecordID=' . $oRecord->RecordID . '">x</a> </tr>'; } $sHTML .= '</table>'; return $sHTML; }