StoreCreateAccount.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Site;
  7. class StoreCreateAccount extends \We7Table {
  8. protected $tableName = 'site_store_create_account';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uid',
  12. 'uniacid',
  13. 'type',
  14. 'endtime',
  15. );
  16. protected $default = array(
  17. 'uid' => '',
  18. 'uniacid' => '',
  19. 'type' => '',
  20. 'endtime' => '',
  21. );
  22. public function getByUniacid($uniacid) {
  23. return $this->where('uniacid', $uniacid)->get();
  24. }
  25. public function getQueryJoinAccountTable($uid = 0, $type = 0) {
  26. $query = $this->query
  27. ->from($this->tableName, 'a')
  28. ->leftjoin('account', 'b')
  29. ->on('a.uniacid', 'b.uniacid');
  30. if ($uid > 0) {
  31. $query->where('a.uid', intval($uid));
  32. }
  33. if (!is_array($type) && $type > 0) {
  34. $type = array(intval($type));
  35. }
  36. if (is_array($type)) {
  37. $query->where('a.type', $type);
  38. }
  39. return $query;
  40. }
  41. public function getUserCreateNumByType($uid, $type)
  42. {
  43. $account_all_type_sign = uni_account_type_sign();
  44. $contain_type = $account_all_type_sign[$type]['contain_type'];
  45. return $this->getQueryJoinAccountTable($uid, $contain_type)->getcolumn('count(*)');
  46. }
  47. public function getUserDeleteNum($uid, $type) {
  48. if (!is_array($type)) {
  49. $type = array(intval($type));
  50. }
  51. $sql = "SELECT COUNT(*) FROM "
  52. . tablename($this->tableName)
  53. . " as a LEFT JOIN " . tablename('account')
  54. . " as b ON a.uniacid = b.uniacid WHERE a.uid = :uid AND a.type IN :type AND (b.isdeleted = 1 OR b.uniacid is NULL)";
  55. return pdo_fetchcolumn($sql, array(':uid' => $uid, ':type' => $type));
  56. }
  57. }