Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question