D
D
DiaTM2017-03-22 15:23:55
PHP
DiaTM, 2017-03-22 15:23:55

Do I need to use PDO or $mysqli->prepare if queries are handled by a function?

public function clear_str($str){
      if(is_array($str)){
        $row = array();
        foreach($str as $key => $item){
          $row[$key] = trim(strip_tags($item));
        }
        return $row;
      }
      return trim(strip_tags($str));
    }

public function cat_articles($id_cat){
      $sql = "SELECT `articles_id`, 
              `title`, 
              `keywords`, 
              `description`, 
              `date`, 
              `author`, 
              `articles_image`, 
              `short_text`, 
              `full_text`, 
              `category_id`, 
              `visible` FROM `articles` WHERE `category_id` = '{$id_cat}' AND `visible` = '1'";
      $result = $this -> ins_db -> query($sql);
      if(!$result){
        throw new DbException('Ошибка запроса: '.$this -> ins_db -> connect_errno.' | '.$this -> ins_db -> connect_error);
      }
      if($result -> num_rows === 0) return FALSE;
      for($i = 0; $i < $result -> num_rows; $i++){
        $row[] = $result -> fetch_assoc();
      }
      return $row;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shagguboy, 2017-03-22
@DiaTM

this function does nothing useful. only the processor heats up.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question