<?php
require('database.php');
$db = new SafeMySQL();
class Add
{
public function showphotos() {
global $db;
$data = $db->getAll("SELECT * FROM photos");
echo json_encode($data);
}
}
$test = new Add();
$test->showphotos();
<?php
require('database.php');
class Add
{
protected $db;
public function __construct(SafeMySQL $db)
{
$this->db = $db;
}
public function showphotos() {
$data = $this->db->getAll("SELECT * FROM photos");
echo json_encode($data);
}
}
$db = new SafeMySQL();
$test = new Add($db);
$test->showphotos();
1. Хранить в базе ещё и тип и плодить два условие типа.
If ($social->canPostOnWall($entity) {
$social->postOnWall($entity);
}
$str = 'select `field` from `' . $table . '` where id = "' . $val . '"';
$str = sprintf(
"select `%s` from `%s` where `id` = '%d'",
$field,
$table,
$id
);
md5(123) = 202cb962ac59075b964b07152d234b70
берем первый символ хеша - 2, создаем папку "2" в /uploads/images
берем второй символ хеша - 0, создаем папку "0" в /uploads/images/2
создаем папку "202cb962ac59075b964b07152d234b70" в /uploads/images/2/0/
кладём в /uploads/images/2/0/202cb962ac59075b964b07152d234b70 нужные файлы
Table "public.social_account"
Column | Type | Modifiers
-------------+--------------------------------+-----------
user_id | integer | not null
network | character varying(255) | not null
external_id | character varying(255) | not null
created_at | timestamp(0) without time zone | not null
updated_at | timestamp(0) without time zone | not null
id | uuid | not null
Indexes:
"social_account_pkey" PRIMARY KEY, btree (id)
"unique_social_account" UNIQUE, btree (network, external_id)
"idx_f24d8339a76ed395" btree (user_id)
Foreign-key constraints:
"fk_f24d8339a76ed395" FOREIGN KEY (user_id) REFERENCES app_user(id) ON DELETE CASCADE
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
2014/10/31 05:38:26 [error] 17743#0: *7174 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"