/** * Busca todas as despesas de um determinado m�s * * @param long $mes * @param long $ano * * @return array */ function busca_mes($mes, $ano, $id_estudio = FALSE) { $colecao = array(); $timestamp_inicio = mktime(0, 0, 1, $mes, 1, $ano); $timestamp_fim = mktime(23, 59, 59, $mes + 1, 0, $ano); $data_inicio = date(FORMATO_DATA_MYSQL, $timestamp_inicio); $data_fim = date(FORMATO_DATA_MYSQL, $timestamp_fim); $this->db->select($this->get_table_name() . '.id,' . $this->get_fields()); $this->db->from($this->get_table_name()); $this->db->join('aluno', 'aluno.id = ' . $this->get_table_name() . '.id_aluno'); if (FALSE !== $id_estudio) { $this->db->where('aluno.id_estudio', $id_estudio); } $this->db->where('data_pagamento >=', $data_inicio); $this->db->where('data_pagamento <=', $data_fim); $query = $this->db->get(); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $pagamento = new Pagamento(); $pagamento->populate($row); array_push($colecao, $pagamento); } } return $colecao; }