예제 #1
0
 public function addParent(Parents $parent)
 {
     $parent->save();
     $this->parents[] = $parent;
     $mapper = DbSingleton::getParentChildrenMapper();
     $mapper->addRelation($parent, $this);
 }
예제 #2
0
<?php

define('APPLICATION_PATH', __DIR__ . '/../');
define('CONFIG', APPLICATION_PATH . '/configs/config.json');
require_once APPLICATION_PATH . "vendor/autoload.php";
$config = new \Noodlehaus\Config(CONFIG);
$app = new Silex\Application();
$app['debug'] = $config->get('debug');
$dbOptions = $config->get('db');
define('APP_KEY', $config->get('app_key'));
$app->register(new Silex\Provider\DoctrineServiceProvider(), ['db.options' => $dbOptions]);
\Sasik\Db\DbSingleton::setDb($app['db']);
$app->mount('/', new Sasik\Controllers\IndexControllerProvider());
$app->run();
예제 #3
0
 public function delete()
 {
     $mapper = DbSingleton::getTokensMapper();
     return $mapper->delete($this->id);
 }
예제 #4
0
 * User: sasik
 * Date: 7/17/15
 * Time: 3:05 PM
 */
define('APPLICATION_PATH', __DIR__ . '/../');
define('CONFIG', APPLICATION_PATH . '/configs/config.json');
require_once APPLICATION_PATH . "vendor/autoload.php";
use Sasik\Models\Children;
use Sasik\Models\Parents;
use Sasik\Models\Tokens;
$config = new \Noodlehaus\Config(CONFIG);
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\DoctrineServiceProvider(), ['db.options' => $config->get('db')]);
\Sasik\Db\DbSingleton::setDb($app['db']);
$db = \Sasik\Db\DbSingleton::getDb();
/**
 * ОСТОРОЖНО
 */
foreach (['children', 'parents', 'tokens', 'children_to_parents'] as $table) {
    $query = $db->createQueryBuilder();
    $query->delete($table)->execute();
    //    $db->fetchAll('DELETE FROM ' . $table );
}
//$db->delete('children', []);
//$db->delete('parents', []);
//$db->delete('tokens', []);
//$db->delete('children_to_parents', []);
$childrens = [Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'TestChildren']), Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'Children' . uniqid()])];
saveAll($childrens);
$parents = [Parents::createObj(['login' => 'Parent' . uniqid(), 'password' => uniqid()]), Parents::createObj(['login' => 'TestParent', 'password' => 'ParentPass']), Parents::createObj(['login' => 'Parent' . uniqid(), 'password' => uniqid()]), Parents::createObj(['login' => 'Parent' . uniqid(), 'password' => uniqid()])];
예제 #5
0
 public function save()
 {
     $mapper = DbSingleton::getMessageMapper();
     $params = ['parent_id' => $this->parent_id, 'child_id' => $this->child_id, 'message' => $this->message, 'date' => $this->date];
     $this->doSave($mapper, $params);
 }
예제 #6
0
 public function addChildren(Children $children)
 {
     $children->save();
     $this->childrens[] = $children;
     $mapper = DbSingleton::getParentChildrenMapper();
     $mapper->addRelation($this, $children);
 }