コード例 #1
0
 public static function freeze($tf = true)
 {
     if (!$tf) {
         throw new NotSupportedException("We are getting rid of no-freeze. Talk to @Shoaibi or @Jason");
     }
     parent::freeze($tf);
 }
コード例 #2
0
ファイル: api_csc.php プロジェクト: adexbn/gds_wechat
function _log_focus($openid, $operation, $user_info = NULL)
{
    R::addDatabase('wechat_csc', $GLOBALS['db_wechat_csc_url'], $GLOBALS['db_wechat_csc_user'], $GLOBALS['db_wechat_csc_pass']);
    R::selectDatabase('wechat_csc');
    if (!R::testConnection()) {
        exit('DB failed' . PHP_EOL);
    }
    R::freeze(true);
    try {
        $user = R::getRedBean()->dispense('wxcsc_focus');
        $user->openid = $openid;
        $user->operation = $operation;
        if ($operation == 'focus' && $user_info != NULL) {
            $user->nickname = $user_info['nickname'];
            $user->sex = $user_info['sex'];
            $user->language = $user_info['language'];
            $user->city = $user_info['city'];
            $user->province = $user_info['province'];
            $user->country = $user_info['country'];
        }
        $user_id = R::store($user);
    } catch (Exception $e) {
        header('Content-type:text/json;charset=utf-8');
        echo json_encode(['result' => 'failed', 'error' => 'db error wechat', 'details' => $e->getMessage()]);
        die;
    }
    R::close();
}
コード例 #3
0
 /**
  * Test Chill mode.
  * 
  * @return void
  */
 public function testChill()
 {
     $bean = R::dispense('bean');
     $bean->col1 = '1';
     $bean->col2 = '2';
     R::store($bean);
     asrt(count(R::$writer->getColumns('bean')), 3);
     $bean->col3 = '3';
     R::store($bean);
     asrt(count(R::$writer->getColumns('bean')), 4);
     R::freeze(array('umbrella'));
     $bean->col4 = '4';
     R::store($bean);
     asrt(count(R::$writer->getColumns('bean')), 5);
     R::freeze(array('bean'));
     $bean->col5 = '5';
     try {
         R::store($bean);
         fail();
     } catch (Exception $e) {
         pass();
     }
     asrt(count(R::$writer->getColumns('bean')), 5);
     R::freeze(array());
     $bean->col5 = '5';
     R::store($bean);
     asrt(count(R::$writer->getColumns('bean')), 6);
 }
コード例 #4
0
 public static function setup($db_type = "pgsql", $host = "ec2-54-83-204-228.compute-1.amazonaws.com", $db_name = "d31sdik2uip6li", $username = "******", $password = "******")
 {
     if (!isset(self::$db)) {
         self::$db = R::setup($db_type . ":host=" . $host . "; dbname=" . $db_name, $username, $password);
         R::freeze();
     }
     return self::$db;
 }
コード例 #5
0
ファイル: Database.php プロジェクト: xinerd/SP_ROI
 public function __construct()
 {
     //        parent::__construct(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
     //        R::setup('mysql:host=localhost;dbname=orm', 'root', 'mysqladmin');
     R::setup(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
     R::freeze(TRUE);
     //R::startLogging(); //start logging
     //        R::debug(TRUE);//turns debugging ON
 }
コード例 #6
0
ファイル: ig-db-model.php プロジェクト: Artgorae/wp-artgorae
 /**
  * Connect to database, for more information about redbean, check http://redbeanphp.com/
  * @return RedBean_ToolBox
  */
 protected function __connect()
 {
     if (!is_object(R::$toolbox)) {
         R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD, false);
         R::freeze(true);
         R::setStrictTyping(false);
         //$this->toolbox = RedBean_Setup::kickstart('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD, false);
     }
     return R::$toolbox;
 }
コード例 #7
0
ファイル: Pdoconfig.php プロジェクト: limweb/webappservice
 public static function setup()
 {
     self::init();
     self::$dbh = new PDO('mysql:host=' . self::$server . ';dbname=' . self::$databasename . ';', self::$username, self::$password);
     self::$dbh->query('SET NAMES utf8');
     R::setup(self::$dbh);
     R::debug(true, 1);
     R::freeze(true);
     // self::$logsrv = new SystemlogsService();
     self::$queryLogger = R::getDatabaseAdapter()->getDatabase()->getLogger();
 }
コード例 #8
0
 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @return R
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $rjhRedbeanService = new R();
     $config = $serviceLocator->get('config');
     $rjhRedbeanConfig = $config['rjhredbean'];
     $connection = $rjhRedbeanConfig['connection'];
     $dsn = $connection['dsn'];
     $user = $connection['user'];
     $password = $connection['password'];
     $rjhRedbeanService->setup($dsn, $user, $password);
     $rjhRedbeanService->freeze($rjhRedbeanConfig['freeze']);
     $rjhRedbeanService->debug($rjhRedbeanConfig['debug']);
     return $rjhRedbeanService;
 }
コード例 #9
0
ファイル: rb.php プロジェクト: gpawlik/suited-php-classes
 /**
  * setup a Redbean instance from CosCMS
  */
 public static function connect()
 {
     static $connected = null;
     if (!$connected) {
         $url = conf::getMainIni('url');
         $username = conf::getMainIni('username');
         $password = conf::getMainIni('password');
         R::setup($url, $username, $password);
         $freeze = conf::getMainIni('rb_freeze');
         if ($freeze == 1) {
             R::freeze(true);
         }
         $connected = true;
     }
 }
コード例 #10
0
ファイル: Database.php プロジェクト: Yusuke-KOMIYAMA/sop
 public static function setupRedBean()
 {
     try {
         if (!self::$_redBeanInitialized) {
             self::$_redBeanInitialized = true;
             R::setup(Config::get('database_dsn'), Config::get('database_user'), Config::get('database_password'));
             R::freeze(true);
             R::exec('SET NAMES utf8');
             define('REDBEAN_MODEL_PREFIX', '\\Sop\\Model\\');
         }
     } catch (\Exception $e) {
         \Sop\Log::error(__FILE__, __LINE__, 'Failed to setup database connection');
         throw $e;
     }
 }
コード例 #11
0
 /**
  * Nuclear test suite.
  * 
  * @return void
  */
 public function testNuke()
 {
     $bean = R::dispense('bean');
     R::store($bean);
     asrt(count(R::$writer->getTables()), 1);
     R::nuke();
     asrt(count(R::$writer->getTables()), 0);
     $bean = R::dispense('bean');
     R::store($bean);
     asrt(count(R::$writer->getTables()), 1);
     R::freeze();
     R::nuke();
     // No effect
     asrt(count(R::$writer->getTables()), 1);
     R::freeze(FALSE);
 }
コード例 #12
0
 /**
  * Begin testing.
  * This method runs the actual test pack.
  *
  * @return void
  */
 public function testBatch()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $page = $redbean->dispense("page");
     $page->name = "page no. 1";
     $page->rating = 1;
     $id1 = $redbean->store($page);
     $page = $redbean->dispense("page");
     $page->name = "page no. 2";
     $id2 = $redbean->store($page);
     $batch = $redbean->batch("page", array($id1, $id2));
     asrt(count($batch), 2);
     asrt($batch[$id1]->getMeta("type"), "page");
     asrt($batch[$id2]->getMeta("type"), "page");
     asrt((int) $batch[$id1]->id, $id1);
     asrt((int) $batch[$id2]->id, $id2);
     $book = $redbean->dispense("book");
     $book->name = "book 1";
     $redbean->store($book);
     $book = $redbean->dispense("book");
     $book->name = "book 2";
     $redbean->store($book);
     $book = $redbean->dispense("book");
     $book->name = "book 3";
     $redbean->store($book);
     $books = $redbean->batch("book", $adapter->getCol("SELECT id FROM book"));
     asrt(count($books), 3);
     $a = $redbean->batch('book', 9919);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     $a = $redbean->batch('triangle', 1);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     R::freeze(TRUE);
     $a = $redbean->batch('book', 9919);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     $a = $redbean->batch('triangle', 1);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     R::freeze(FALSE);
     asrt(R::wipe('spaghettimonster'), FALSE);
 }
コード例 #13
0
function saveMysql($node, $nodeName)
{
    try {
        $record = R::dispense(strtolower($nodeName));
        $properties = $node["n"]->getProperties();
        foreach ($properties as $key => $property) {
            if ($key != "wkt") {
                $record[$key] = $property;
            }
            R::store($record);
        }
        R::freeze(TRUE);
    } catch (Exception $e) {
        echo $e;
        print_r($properties);
        R::freeze(FALSE);
        saveMysql($node, $nodeName);
    }
}
コード例 #14
0
 /**
  * Test count and wipe.
  * 
  * @return void
  */
 public function testCountAndWipe()
 {
     testpack("Test count and wipe");
     $page = R::dispense("page");
     $page->name = "ABC";
     R::store($page);
     $n1 = R::count("page");
     $page = R::dispense("page");
     $page->name = "DEF";
     R::store($page);
     $n2 = R::count("page");
     asrt($n1 + 1, $n2);
     R::wipe("page");
     asrt(R::count("page"), 0);
     asrt(R::$redbean->count("page"), 0);
     asrt(R::$redbean->count("kazoo"), 0);
     // non existing table
     R::freeze(TRUE);
     asrt(R::$redbean->count("kazoo"), 0);
     // non existing table
     R::freeze(FALSE);
     $page = R::dispense('page');
     $page->name = 'foo';
     R::store($page);
     $page = R::dispense('page');
     $page->name = 'bar';
     R::store($page);
     asrt(R::count('page', ' name = ? ', array('foo')), 1);
     // Now count something that does not exist, this should return 0. (just be polite)
     asrt(R::count('teapot', ' name = ? ', array('flying')), 0);
     asrt(R::count('teapot'), 0);
     $currentDriver = $this->currentlyActiveDriverID;
     // Some drivers don't support that many error codes.
     if ($currentDriver === 'mysql' || $currentDriver === 'postgres') {
         try {
             R::count('teaport', ' for tea ');
             fail();
         } catch (RedBean_Exception_SQL $e) {
             pass();
         }
     }
 }
コード例 #15
0
ファイル: R.php プロジェクト: nirgavish/Framework--Apex
function initialize_database(){
	//http://forums.hostgator.com/mysql-password-hashing-php-5-2-t117816.html
	$cfg = lib('config')->db;
	
	switch($cfg['driver']){
		case 'mysql':
			R::setup('mysql:host='.$cfg['host'].';dbname='.$cfg['dbName'],$cfg['username'],$cfg['password']);
			break;
		case 'sqlite':
			$path = explode('/',str_replace('\\','/',__DIR__.'\\..\\..\\'.$cfg['path']));
			array_shift($path);
			$path = implode('/',$path);
			R::setup('sqlite:/'.$path);
			break;
	}
	//$this->prefix = $cfg['prefix'];
	
	if($cfg['frozen']==true){
		R::freeze(true);
	}
}
コード例 #16
0
 /**
  * Handle various admin operations /devel/xxxx
  *
  * The test for developer status is done in index.php so deos not need to be repeated here.
  *
  * @param object	$context	The context object for the site
  *
  * @return string	A template name
  */
 public function handle($context)
 {
     if ($context->hasdeveloper()) {
         $tpl = 'support/devel.twig';
         $rest = $context->rest();
         switch ($rest[0]) {
             case 'hack':
                 # execute some code.
                 R::freeze(FALSE);
                 include 'hack.php';
                 break;
             case 'fail':
                 # this lets you test error handling
                 $x = 2 / 0;
                 break;
             case 'throw':
                 # this lets you test exception handling
                 throw new Exception('Unhandled Exception Test');
             case 'mail':
                 # this lets you test email sending
                 $foo = mail($context->user()->email, 'test', 'test');
                 $context->local()->message('message', 'sent');
                 break;
                 /*
                 		case 'errlog' : # this will show you the contents of the PHP error log file.
                 		    $context->local()->addval('errlog', file_get_contents(Config::PHPLOG));
                 		    exit;
                 
                 		case 'clearlog' :
                 		    fclose(fopen(Config::PHPLOG, 'w'));
                 		    $context->local()->message('message', 'Log Cleared');
                 		    break;
                 */
         }
     } else {
         (new Web())->noaccess();
     }
     return $tpl;
 }
コード例 #17
0
 /**
  * Try to open the BBS DB. If the DB file does not exist we do nothing.
  * Creates also the subdirectories for thumbnails etc. if they don't exist.
  *
  * We open it first as PDO, because we need that for the 
  * authentication library, then we initialize RedBean.
  *
  * @param string  	dataPath 	Path to BBS DB, default = data/data.db
  * @param boolean	freeze 		if true the DB schema is fixed, 
  * 								else RedBeanPHP adapt the schema
  * 								default = true
  */
 function __construct($dataPath = 'data/data.db', $freeze = true)
 {
     $rp = realpath($dataPath);
     $this->data_dir = dirname($dataPath);
     $this->thumb_dir = $this->data_dir . '/titles';
     if (!file_exists($this->thumb_dir)) {
         mkdir($this->thumb_dir);
     }
     $this->authors_dir = $this->data_dir . '/authors';
     if (!file_exists($this->authors_dir)) {
         mkdir($this->authors_dir);
     }
     if (file_exists($rp) && is_writeable($rp)) {
         $this->mydb = new PDO('sqlite:' . $rp, NULL, NULL, array());
         $this->mydb->setAttribute(1002, 'SET NAMES utf8');
         $this->mydb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $this->mydb->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
         $this->last_error = $this->mydb->errorCode();
         R::setup('sqlite:' . $rp);
         R::freeze($freeze);
     } else {
         $this->mydb = NULL;
     }
 }
コード例 #18
0
ファイル: Db.php プロジェクト: WTer/NJB
<?php

require 'App/Model/rb.php';
R::setup('mysql:host=localhost;dbname=NJB', 'root', 'lwsMYSQL2015');
R::freeze(true);
コード例 #19
0
ファイル: pue_month.php プロジェクト: adexbn/gds_alarm
        $relate_6->zhanshileixing = 0;
        $relate_6->guanlianname = '客户用电较上月浮动最大Top5';
        $relate_6->yidongmiaoshu = json_encode($top5, JSON_UNESCAPED_UNICODE);
        $relate_6->guanlianzhi = $run_time;
        if (R::store($relate_6) <= 0) {
            exit('DB relate_6 insert failed \\n');
        }
    }
} catch (Exception $e) {
    exit('DB relate_6 insert failed \\n' . $e->getMessage());
}
R::close();
/* 写入运行日志 */
R::addDatabase('config', $GLOBALS['db_config_url'], $GLOBALS['db_config_user'], $GLOBALS['db_config_pass']);
R::selectDatabase('config');
if (!R::testConnection()) {
    exit('DB config connect failed \\n' . $e->getMessage());
}
R::freeze(TRUE);
try {
    $run_log = R::getRedBean()->dispense('sys_run_log');
    $run_log->alarm_type = $run_type;
    $run_log->last_run = $run_time;
    if (R::store($run_log) <= 0) {
        exit('DB config insert failed \\n');
    }
} catch (Exception $e) {
    exit('DB config insert failed \\n' . $e->getMessage());
}
R::close();
die('Run ' . $run_type . ' at ' . $run_time . ' done');
コード例 #20
0
 /**
  * Test areRelated().
  * 
  * @return void
  */
 public function testAreRelatedAndVariations()
 {
     $sheep = R::dispense('sheep');
     $sheep->name = 'Shawn';
     $sheep2 = R::dispense('sheep');
     $sheep2->name = 'Billy';
     $sheep3 = R::dispense('sheep');
     $sheep3->name = 'Moo';
     R::store($sheep3);
     R::associate($sheep, $sheep2);
     asrt(R::areRelated($sheep, $sheep2), TRUE);
     R::exec('DELETE FROM sheep_sheep WHERE sheep2_id = ? -- keep-cache', array($sheep2->id));
     asrt(R::areRelated($sheep, $sheep2), FALSE);
     // Use cache?
     R::associate($sheep, $sheep2);
     R::$writer->setUseCache(TRUE);
     asrt(R::areRelated($sheep, $sheep2), TRUE);
     R::exec('DELETE FROM sheep_sheep WHERE sheep2_id = ? -- keep-cache', array($sheep2->id));
     asrt(R::areRelated($sheep, $sheep2), TRUE);
     // Use cache?
     R::associate($sheep, $sheep2);
     asrt(R::areRelated($sheep, $sheep3), FALSE);
     $pig = R::dispense('pig');
     asrt(R::areRelated($sheep, $pig), FALSE);
     R::freeze(TRUE);
     asrt(R::areRelated($sheep, $pig), FALSE);
     R::freeze(FALSE);
     $foo = R::dispense('foo');
     $bar = R::dispense('bar');
     $foo->id = 1;
     $bar->id = 2;
     asrt(R::areRelated($foo, $bar), FALSE);
 }
コード例 #21
0
ファイル: app.php プロジェクト: rodrigopolo/todo-app
// Set Time zone
date_default_timezone_set("UTC");
// SlimPHP portable route fix
$_SERVER['SCRIPT_NAME'] = preg_replace('/public\\/index\\.php$/', 'index.php', $_SERVER['SCRIPT_NAME'], 1);
// Load Config
require 'app/config.php';
// Autoload
require 'vendor/autoload.php';
// RedBeanPHP alias fix
class R extends RedBeanPHP\Facade
{
}
// RedBeanPHP setup
R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USERNAME, DB_PASSWORD);
R::freeze(DB_FREEZE);
// Slim app instance
$app = new \Slim\Slim(['view' => new EnhancedView()]);
// Slim Config
$app->config(['templates.path' => 'app/views', 'debug' => APP_DEBUG]);
// Add support for JSON posts
$app->add(new \Slim\Middleware\ContentTypes());
// JSON view function
function APIrequest()
{
    $app = \Slim\Slim::getInstance();
    $app->view(new \JsonView());
    $app->view->clear();
}
// Set webroot for portable
$app->hook('slim.before', function () use($app) {
コード例 #22
0
 /**
  * Set up local information. Returns self
  *
  * The $loadrb parameter simplifies some of the unit testing for this class
  *
  * @param string	$basedir	The full path to the site directory
  * @param boolean	$ajax		If TRUE then this is an AJAX call
  * @param boolean	$debug		If TRUE then we are developing the system
  * @param boolean	$loadtwig	if TRUE then load in Twig.
  * @param boolean	$loadrb		if TRUE then load in RedBean
  *
  * @return object
  */
 public function setup($basedir, $ajax, $debug, $loadtwig, $loadrb = TRUE)
 {
     #
     # For a fixed place production system you probably just want to replace all the directory munging with constants!
     #
     $this->basepath = $basedir;
     #    $bd = $basedir;
     #    $bdr = array();
     #    while ($bd != $_SERVER['DOCUMENT_ROOT'])
     #    {
     #	$pp = pathinfo($bd);
     #	$bd = $pp['dirname'];
     #	$bdr[] = $pp['basename'];
     #    }
     $this->basedname = Config::BASEDNAME;
     $this->ajax = $ajax;
     $this->debug = $debug;
     /*
      * Set up all the system error handlers
      */
     set_exception_handler(array($this, 'exception_handler'));
     set_error_handler(array($this, 'error_handler'));
     register_shutdown_function(array($this, 'shutdown'));
     if ($loadtwig) {
         # we want twig - there are some autoloader issues out there that addign twig seems to fix....
         $this->setuptwig($debug, FALSE);
     }
     if (file_exists($this->makepath($this->basepath, 'offline'))) {
         # go offline before we try to do anything else...
         $this->render('offline.twig', array('msg' => file_get_contents($this->makepath($basedir, 'offline'))));
         exit;
     }
     /*
      * Initialise database access
      */
     require_once 'rb.php';
     # RedBean interface
     if (Config::DBHOST != '' && $loadrb) {
         # looks like there is a database configured
         R::setup('mysql:host=' . Config::DBHOST . ';dbname=' . Config::DB, Config::DBUSER, Config::DBPW);
         # mysql initialiser
         R::freeze(!$debug);
         # freeze DB for production systems
     }
     return $this;
 }
コード例 #23
0
 fputs($fd, 'RewriteBase ' . ($dir === '' ? '/' : $dir) . PHP_EOL);
 fputs($fd, 'RewriteRule ^(ajax.*) $1 [L,NC,QSA]' . PHP_EOL . 'RewriteRule ^(assets)/(.*) $1/$2 [L,NC]' . PHP_EOL . 'RewriteRule ^.*$ index.php [L,QSA]' . PHP_EOL);
 fclose($fd);
 /*
  * Try opening the database and setting up the User table
  */
 require 'rb.php';
 try {
     $now = r::isodatetime(time() - date('Z'));
     # make sure the timestamp is in UTC (this should fix a weird problem with some XAMPP installations)
     $vals['dbhost'] = $cvalue['dbhost'];
     $vals['dbname'] = $cvalue['dbname'];
     $vals['dbuser'] = $cvalue['dbuser'];
     R::setup('mysql:host=' . $cvalue['dbhost'] . ';dbname=' . $cvalue['dbname'], $cvalue['dbuser'], $cvalue['dbpass']);
     # mysql initialiser
     R::freeze(FALSE);
     R::nuke();
     # clear everything.....
     $user = R::dispense('user');
     $user->email = $cvalue['email'];
     $user->login = $cvalue['admin'];
     $user->password = password_hash($cvalue['adminpw'], PASSWORD_DEFAULT);
     $user->active = 1;
     $user->confirm = 1;
     $user->joined = $now;
     R::store($user);
     /**
      * Now initialise the confirmation code table
      */
     $conf = R::dispense('confirm');
     $conf->code = 'this is a rubbish code';
コード例 #24
0
 /**
  * Tests whether we can store an empty bean.
  * An empty bean has no properties, only ID. Normally we would
  * skip the ID field in an INSERT, this test forces the driver
  * to specify a value for the ID field. Different writers have to
  * use different values: Mysql uses NULL to insert a new auto-generated ID,
  * while Postgres has to use DEFAULT.
  */
 public function testEmptyBean()
 {
     testpack('Test Empty Bean Storage.');
     R::nuke();
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 1);
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 2);
     //also test in frozen mode
     R::freeze(TRUE);
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 3);
     R::freeze(FALSE);
 }
コード例 #25
0
ファイル: make-db.php プロジェクト: BrokenSilence/malgraph4
		finished_episodes INTEGER,
		finished_chapters INTEGER,
		finished_volumes INTEGER
	)');
    R::exec('CREATE INDEX IF NOT EXISTS idx_usermedia_user_id ON usermedia (user_id)');
    R::exec('CREATE INDEX IF NOT EXISTS idx_usermedia_score ON usermedia(score)');
    R::exec('CREATE INDEX IF NOT EXISTS idx_usermedia_media_score ON usermedia(media,score)');
    R::exec('CREATE INDEX IF NOT EXISTS idx_usermedia_media_mal_id ON usermedia(media,mal_id)');
    foreach (Database::getAllDbNames() as $dbName) {
        $path2 = Config::$dbPath . DIRECTORY_SEPARATOR . $dbName;
        copy($path1, $path2);
    }
    unlink($path1);
    Database::loadDatabase('media.sqlite');
    R::freeze(false);
    R::exec('CREATE TABLE IF NOT EXISTS media (
		id INTEGER PRIMARY KEY,
		mal_id INTEGER,
		media VARCHAR(1),
		title VARCHAR(96),
		sub_type INTEGER,
		picture_url VARCHAR(256),
		average_score FLOAT,
		average_score_users INTEGER,
		ranking INTEGER,
		popularity INTEGER,
		members INTEGER,
		favorites INTEGER,
		publishing_status VARCHAR(1),
		published_from VARCHAR(10), --TIMESTAMP
コード例 #26
0
ファイル: RedBeanDatabase.php プロジェクト: youprofit/Zurmo
 /**
  * Unfreezes the database. This means that RedBean can dynamically
  * modify the database as it executes during development.
  */
 public static function unfreeze()
 {
     R::freeze(false);
 }
コード例 #27
0
define('MODEL_PATH', 'models/');
define('VIEWS_PATH', 'views');
define('CONTROLLER_PATH', 'controllers/');
// CORE THEME SETTINGS
define('THEME_PATH', APP_THEME . '/');
define('THEME_ASSETS', BASE_URL . VIEWS_PATH . '/' . THEME_PATH . 'assets/');
// ADMIN THEME SETTINGS
define('ADMIN_THEME', 'admin/');
define('ADMIN_ASSETS', BASE_URL . VIEWS_PATH . '/' . ADMIN_THEME . 'assets/');
// LOAD ALL MODEL CLASSES
foreach (glob(MODEL_PATH . "*.php") as $class) {
    require_once $class;
}
// REDBEAN ORM CONFIG
R::setup("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASS);
if (APP_MODE == 'production') {
    R::freeze();
}
// SLIM MICROFRAMEWORK
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
// SLIM CSRF GUARD
require 'Slim/Extras/Middleware/CsrfGuard.php';
$app = new \Slim\Slim(array('mode' => APP_MODE, 'templates.path' => VIEWS_PATH));
$app->add(new \Slim\Extras\Middleware\CsrfGuard());
$app->notFound(function () use($app) {
    $app->flash('danger', 'The page you are looking for could not be found.');
    $url = userIsValid() ? ADMIN_MANAGE : BASE_URL;
    $app->redirect($url);
});
$app->flashKeep();
コード例 #28
0
 function __construct()
 {
     parent::__construct();
     $this->load->library('rb');
     R::freeze(TRUE);
 }
コード例 #29
0
ファイル: BaseModel.php プロジェクト: andreyyec/webSM
 public function _openDBConnection()
 {
     R::setup('pgsql:host=localhost;dbname=postgres', 'postgres', 'Admin123');
     R::freeze(1);
 }
コード例 #30
0
 /**
  * Tests whether we can update or unset a parent bean
  * with an alias without having to use fetchAs and
  * without loading the aliased bean causing table-not-found
  * errors.
  */
 public function testUpdatingParentBeansWithAliases()
 {
     testpack('Test updating parent beans with aliases');
     R::nuke();
     $trans = R::dispense('transaction');
     $seller = R::dispense('user');
     $trans->seller = $seller;
     $id = R::store($trans);
     R::freeze(true);
     $trans = R::load('transaction', $id);
     //should not try to load seller, should not require fetchAs().
     try {
         $trans->seller = R::dispense('user');
         pass();
     } catch (Exception $e) {
         fail();
     }
     $trans = R::load('transaction', $id);
     //same for unset...
     try {
         unset($trans->seller);
         pass();
     } catch (Exception $e) {
         fail();
     }
     R::freeze(false);
     $account = R::dispense('user');
     asrt(count($account->alias('seller')->ownTransaction), 0);
     $account->alias('seller')->ownTransaction = R::dispense('transaction', 10);
     $account->alias('boo');
     //try to trick me...
     $id = R::store($account);
     R::freeze(true);
     $account = R::load('user', $id);
     asrt(count($account->alias('seller')->ownTransaction), 10);
     //you cannot unset a list
     unset($account->alias('seller')->ownTransaction);
     $id = R::store($account);
     $account = R::load('user', $id);
     asrt(count($account->alias('seller')->ownTransaction), 10);
     $account->alias('seller')->ownTransaction = array();
     $id = R::store($account);
     $account = R::load('user', $id);
     asrt(count($account->alias('seller')->ownTransaction), 0);
     asrt(count($account->ownTransaction), 0);
     R::freeze(false);
     //but also make sure we don't cause extra column issue #335
     R::nuke();
     $building = R::dispense('building');
     $village = R::dispense('village');
     $building->village = $village;
     R::store($building);
     $building = $building->fresh();
     $building->village = NULL;
     R::store($building);
     $building = $building->fresh();
     $columns = R::inspect('building');
     asrt(isset($columns['village']), false);
     asrt(isset($building->village), false);
     R::nuke();
     $building = R::dispense('building');
     $village = R::dispense('village');
     $building->village = $village;
     R::store($building);
     $building = $building->fresh();
     unset($building->village);
     R::store($building);
     $building = $building->fresh();
     $columns = R::inspect('building');
     asrt(isset($columns['village']), false);
     asrt(isset($building->village), false);
     $building = R::dispense('building');
     $village = R::dispense('village');
     $building->village = $village;
     R::store($building);
     $building = $building->fresh();
     $building->village = false;
     R::store($building);
     $building = $building->fresh();
     $columns = R::inspect('building');
     asrt(isset($columns['village']), false);
     asrt(isset($building->village), false);
 }