<commit_before><?php
/**
 * Created by PhpStorm.
 * User: brolaugh
 * Date: 2/25/16
 * Time: 9:22 PM
 */

namespace App\database;


class Select extends dbSetup
{

  /**
   * @return array
   */
  public function getAllTasks()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM task");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  /**
   * @return array
   */
  public function getAllUnFinishedTasks()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM status");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  public function getAllDoneTasks()
  {
    $stmt = $this->getDb()->prepare("");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  /**
   * @return object array
   */
  public function getAllTasksWithStatus()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM task_with_status");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  public function getAllStatusLevels()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM status_level");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  /**
   * @param int array $taskID
   */
  public function getTasksWithFollowingStatus($taskID=array(1))
  {
    $query = "SELECT task_with_status.id as id, title, description, user, level, stamp, task_with_status.style_class as style_class, status_level.id as level_id FROM `task_with_status` LEFT JOIN status_level ON task_with_status.level=status_level.plain_text";
    $param = "";
    $secondParam = &$taskID;
    if (count($taskID) > 0) {
      $query .= " WHERE status_level.id IN(";
      for ($i = 0; $i < count($taskID); $i++) {
        if ($i != count($taskID) - 1)
          $query .= "?,";
        else
          $query .= "?";
        $param .= "i";
      }

      $query .= ")";
    }

    array_push($secondParam, $param);
    $secondParam = array_reverse($secondParam);
    var_dump($query);
    var_dump($param);
    var_dump($secondParam);
    $stmt = $this->getDb()->prepare($query);
    call_user_func_array(array($stmt, "bind_param"), $secondParam);
    var_dump($stmt->execute());
  }
}<commit_msg>Cleaned up after previous commits and added return segment to getTasksWith...<commit_after><?php
/**
 * Created by PhpStorm.
 * User: brolaugh
 * Date: 2/25/16
 * Time: 9:22 PM
 */

namespace App\database;


class Select extends dbSetup
{

  /**
   * @return array
   */
  public function getAllTasks()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM task");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  /**
   * @return array
   */
  public function getAllUnFinishedTasks()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM status");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  public function getAllDoneTasks()
  {
    $stmt = $this->getDb()->prepare("");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  /**
   * @return object array
   */
  public function getAllTasksWithStatus()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM task_with_status");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  public function getAllStatusLevels()
  {
    $stmt = $this->getDb()->prepare("SELECT * FROM status_level");
    $stmt->execute();
    $res = $stmt->get_result();
    $a = array();
    while ($row = $res->fetch_object()) {
      array_push($a, $row);
    }
    $stmt->close();
    return $a;
  }

  /**
   * @param int array $taskID
   */
  public function getTasksWithFollowingStatus($taskID=array(1))
  {
    $query = "SELECT task_with_status.id as id, title, description, user, level, stamp, task_with_status.style_class as style_class, status_level.id as level_id FROM `task_with_status` LEFT JOIN status_level ON task_with_status.level=status_level.plain_text";
    $param = "";
    $secondParam = &$taskID;
    if (count($taskID) > 0) {
      $query .= " WHERE status_level.id IN(";
      for ($i = 0; $i < count($taskID); $i++) {
        if ($i != count($taskID) - 1)
          $query .= "?,";
        else
          $query .= "?";
        $param .= "i";
      }

      $query .= ")";
    }
    array_push($secondParam, $param);
    $secondParam = array_reverse($secondParam);
    $stmt = $this->getDb()->prepare($query);
    call_user_func_array(array($stmt, "bind_param"), $secondParam);
    $stmt->execute();
    $res = $stmt->get_result();

    $a = array();
    while($row = $res->fetch_object()){
      $a[] = $row;
    }
    return $a;
  }
}
{'fraction_non_alphanumeric': 0.19394699140401145, 'fraction_numerical': 0.004297994269340974, 'mean_word_length': 2.703580901856764, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2606505', 'n_tokens_mistral': 1965, 'n_tokens_neox': 1922, 'n_words': 399}