grigory51

Mapper

May 28th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2.  
  3. class PluginMaterial_ModuleMaterial_MapperMaterial extends Mapper {
  4.  
  5. public function AddWithOutCommit($oMaterial) {
  6. $sql = "INSERT INTO " . Config::Get('db.table.material') . "
  7. (material_type, material_link, material_name, material_description, material_params, material_commit)
  8. VALUES (?, ?, ?, ?, ?);";
  9. $iId = $this->oDb->query($sql, $oMaterial->getType(), $oMaterial->getLink(), $oMaterial->getName(), $oMaterial->getDescription(), $oMaterial->getParams(), false);
  10. if ($iId) {
  11. return $iId;
  12. }
  13. return false;
  14. }
  15.  
  16. public function GetAll() {
  17. $sql = 'SELECT * FROM ' . Config::Get('db.table.material') . ' WHERE ' . Config::Get('db.table.material') . '.material_commit = TRUE';
  18. $aResult = array();
  19. if ($aRows = $this->oDb->query($sql)) {
  20. foreach ($aRows as $aRow) {
  21. $aResult[] = Engine::GetEntity('PluginMaterial_ModuleMaterial_Entity' . $aRow['material_type'] . 'Material', $aRow);
  22. }
  23. }
  24. return $aResult;
  25. }
  26. }
  27.  
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment