ExtraTemplates.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. namespace We7\Table\Users;
  7. class ExtraTemplates extends \We7Table {
  8. protected $tableName = 'users_extra_templates';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uid',
  12. 'template_id',
  13. );
  14. protected $default = array(
  15. 'uid' => '',
  16. 'template_id' => '',
  17. );
  18. public function addExtraTemplate($uid, $template_id) {
  19. $data = array(
  20. 'uid' => $uid,
  21. 'template_id' => $template_id,
  22. );
  23. $res = $this->fill($data)->save();
  24. return $res;
  25. }
  26. public function getExtraTemplateByUidAndTemplateid($uid, $template_id) {
  27. $where = array(
  28. 'uid' => $uid,
  29. 'template_id' => $template_id,
  30. );
  31. $extra_template = $this->where($where)->get();
  32. return $extra_template;
  33. }
  34. public function getExtraTemplatesByUid($uid) {
  35. return $this->where(array('uid' => $uid))->get();
  36. }
  37. public function getExtraTemplatesIdsByUid($uid) {
  38. return $this->where(array('uid' => $uid))->getall('template_id');
  39. }
  40. public function deleteExtraTemplatesByUid($uid) {
  41. return $this->where(array('uid' => $uid))->delete();
  42. }
  43. }