示例#1
0
 /**
  * Select request
  * @param bool $many
  * @param array|string $_key
  * @param array $where
  * @param string $type
  * @param string $beforeFrom
  * @param string $beforeWhere
  * @param string $afterWhere
  * @return array|mixed
  */
 private function select($many, $_key, $where = [], $type = 'AND', $beforeFrom = '', $beforeWhere = '', $afterWhere = '')
 {
     $sqlData = [];
     $key = DfSql::prepareKeys($_key);
     $sql = "SELECT {$key} {$beforeFrom} FROM {$this->table} {$beforeWhere}";
     if (!empty($where)) {
         $whereData = implode(" {$type} ", DfSql::makePlaceholders($where, false)['array']);
         $sqlData = DfSql::makePlaceholders($where, false)['data'];
         $sql .= " WHERE {$whereData}";
     }
     $sql .= (!empty($where) ? ' ' : ' WHERE ') . $afterWhere;
     return $many === true ? $this->db->getRecordsByQuery($sql, $sqlData) : $this->db->getRecordByQuery($sql, $sqlData);
 }