46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
abstract class BaseModel {
|
|
public $db = null;
|
|
|
|
// public $agent = null;
|
|
public $sphinx2 = null;
|
|
// public $agent = $this->agent;
|
|
public function __construct()
|
|
{
|
|
// global $agent;
|
|
$pdo = new MysqlPdo(hst, ndb, user, pass);
|
|
$sql = "SET NAMES 'utf8mb4'";
|
|
$pdo->query($sql);
|
|
$this->db = $pdo;
|
|
// $this->agent = $agent;
|
|
}
|
|
public function set_sphinx2(){
|
|
$pdo = new MysqlPdo(hstsph2, null, null, null, true, '9306');
|
|
$sql = "SET NAMES 'utf8mb4'";
|
|
$pdo->query($sql);
|
|
$this->sphinx2 = $pdo;
|
|
}
|
|
|
|
public function arrToString($array) {
|
|
return implode(',', array_map('intval', $array));
|
|
|
|
}
|
|
|
|
public static function clearInput($string) { // очистка входящего элимента
|
|
$string = strip_tags($string); // от тегов
|
|
$string = htmlspecialchars($string); // от кавычек и прочего
|
|
$string = str_replace("\n", "<br>", $string);
|
|
$string = str_replace("\r", "", $string);
|
|
$string = mysql_real_escape_string($string); // от MySQL-инъекций
|
|
$string = trim($string); // от лишних пробелов
|
|
$string = stripslashes($string); // от слэшей
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
// public function agent() {
|
|
// global $agent;
|
|
// return $this.$agent;
|
|
// }
|
|
} |