url: "/posts/add/addPost",
method: 'POST',
//data: window.fdPost,
data: {
"name": name,
"desc": desc,
"cat": cat,
"data": window.fdPost
},
cache: !1,
dataType: 'text',
processData: !1,
contentType: !1,
timeout: 60000,
name = $('#name').val(), desc = $('#desc').val(), cat = $('#cat :selected').val();
data = {
"name " : name ,
"desc " : desc ,
"cat" : cat,
"data" : window.fdPost
}
if (name.length && desc.length && cat.length) {
$.ajax({
url: "/posts/add/addPost",
method: 'POST',
//data: window.fdPost,
data: data,
$web_files = @$this->request->files;//загруженные файлы с сайта
var_dump($web_files);
echo "\n";
var_dump($this->request->post);
class bdPdo
{
public $pdo;
private $count = 0;
public function __construct() {
//$hostname, $user, $password, $dbname
$host = 'хост';
$db = 'база данных';
$user = 'имя базы данных';
$pass = 'пароль от базы данных';
$charset = 'utf8';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$this->pdo = new PDO($dsn, $user, $pass, $opt);
}
}
79 $s = $this->db;
80 $query = $this->db->query($sql);
81 $s .= $query;
82 $result = $s;
29 public function query($sql) {
30 $resource = mysqli_query($this->link, $sql);
31
32 $this->count++;
34
35 if ($resource) {
36 if (is_resource($resource)) {
37 $i = 0;
38 $data = array();
39
40 while($result = mysqli_fetch_assoc($resource)) {
41 $data[$i] = $result;
42 $i++;
43 }
44
45 mysqli_free_result($resource);
46
47 $query = new stdClass();
48 $query->row = isset($data[0]) ? $data[0] : array();
49 $query->rows = $data;
50 $query->num_rows = $i;
51
52 unset($data);
53 return $query;
54 } else {
55 return true;
56 }
57 }
58 }