<?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();
var elems = document.getElementsByClassName('dateOnline');
for (var i = 0; i < elems.length; i++) {
elems[i].innerHTML = '<span>' + time.getDate() + " " + month[time.getMonth()] + '</span>';
}
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
DependencyInjection/AcmeAppExtension.php
.<?php
namespace Acme\AppBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
* This is the class that loads and manages your bundle configuration.
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
* @codeCoverageIgnore
*/
class AcmeAppExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$this->processConfiguration($configuration, $configs);
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../config/'));
$loader->load('services.php');
if ($container->getParameter('kernel.environment') == 'dev') {
$loader->load('services_dev.php');
}
if ($container->getParameter('kernel.environment') == 'test') {
$loader->load('services_test.php');
}
}
}
// 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.');
}
cp /etc/project_name.yml /var/www/project_name/app/config/parameters.yml
.