コード例 #1
0
 /**
  * Test if RedBeanPHP can properly handle keywords.
  * 
  * @return void
  */
 public function testKeywords()
 {
     $keywords = array('anokeyword', 'znokeyword', 'group', 'DROP', 'inner', 'JOIN', 'select', 'table', 'int', 'cascade', 'float', 'CALL', 'in', 'status', 'order', 'limit', 'having', 'else', 'if', 'while', 'distinct', 'like');
     R::setStrictTyping(FALSE);
     RedBean_OODBBean::setFlagBeautifulColumnNames(FALSE);
     foreach ($keywords as $k) {
         R::nuke();
         $bean = R::dispense($k);
         $bean->{$k} = $k;
         $id = R::store($bean);
         $bean = R::load($k, $id);
         $bean2 = R::dispense('other');
         $bean2->name = $k;
         $bean->bean = $bean2;
         $bean->ownBean[] = $bean2;
         $bean->sharedBean[] = $bean2;
         $id = R::store($bean);
         R::trash($bean);
         pass();
     }
     RedBean_OODBBean::setFlagBeautifulColumnNames(TRUE);
     R::setStrictTyping(TRUE);
 }
コード例 #2
0
$default_config['default_sql_limit'] = array(0, 25);
$default_config['rate_limit'] = 100;
$config = array_merge($default_config, $config);
if (file_exists('config.php.default') && $config['debug'] === false) {
    die('Please remove the config.php.default.');
}
require_once 'utils.php';
/* make sure admin pass has changed */
if ($config['password'] === 'admin') {
    die('Change the password in config.php');
}
/* setup database */
use RedBean_Facade as R;
R::setup($config['db_conn'], $config['db_user'], $config['db_pass']);
R::$writer->setUseCache(false);
RedBean_OODBBean::setFlagBeautifulColumnNames(false);
/* app start */
if ($config['debug'] === false) {
    ini_set('display_errors', '0');
}
$app = new \Slim\Slim(array('debug' => $config['debug'], 'templates.path' => 'templates'));
/* Middlewares */
$r = new Util($app);
/* load hooks */
$r->loadHooks();
function API()
{
    $app = \Slim\Slim::getInstance();
    $app->view(new \JsonApiView());
    $app->add(new \JsonApiMiddleware());
    $app->response->headers->set('Content-Type', 'application/json');