本文整理汇总了PHP中RedBeanPHP\Facade类的典型用法代码示例。如果您正苦于以下问题:PHP Facade类的具体用法?PHP Facade怎么用?PHP Facade使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Facade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResults
/**
* @return array
*/
public function getResults()
{
if ($this->storedNumber > $this->maxResults) {
$startFrom = $this->maxResults * $this->startPage;
$extraSQL = 'ORDER BY id ASC LIMIT ' . $startFrom . ',' . $this->maxResults;
return Facade::findAll($this->DBTable, $extraSQL);
} else {
return Facade::findAll($this->DBTable);
}
}
示例2: testDatabaseInstallation
public function testDatabaseInstallation()
{
$this->url('index.php');
//All Fields initially with empty
$this->fillFields(array('hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'phpback_test', 'adminemail' => 'admin@phpback.org', 'adminname' => 'admin', 'adminpass' => 'admin', 'adminrpass' => 'admin'));
//Submit form
$this->byName('install-form')->submit();
//Should delete first intallation files
$this->assertFileNotExists('install/index.php');
$this->assertFileNotExists('install/install1.php');
$this->assertFileNotExists('install/database_tables.sql');
//Should create configuration file
$this->assertFileExists('application/config/database.php');
include 'application/config/database.php';
$this->assertEquals($db['default']['username'], 'root');
$this->assertEquals($db['default']['password'], '');
$this->assertEquals($db['default']['database'], 'phpback_test');
$this->assertEquals($db['default']['username'], 'root');
$this->assertEquals($db['default']['dbdriver'], 'mysqli');
//Should have updated database with new tables
$this->assertEquals(RedBean::inspect(), array('_sessions', 'categories', 'comments', 'flags', 'ideas', 'logs', 'settings', 'users', 'votes'));
//Should have created the admin user
$adminUser = RedBean::load('users', 1);
$this->assertEquals($adminUser->name, 'admin');
$this->assertEquals($adminUser->email, 'admin@phpback.org');
$this->assertEquals($adminUser->isadmin, '3');
$this->assertEquals($adminUser->votes, '20');
}
示例3: testGetInsertID
/**
* Tests R::getInsertID convenience method.
*
* @return void
*/
public function testGetInsertID()
{
R::nuke();
$id = R::store(R::dispense('book'));
$id2 = R::getInsertID();
asrt($id, $id2);
}
示例4: testRebuilder
/**
* Test SQLite table rebuilding.
*
* @return void
*/
public function testRebuilder()
{
$toolbox = R::getToolBox();
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
$book = R::dispense('book');
$page = R::dispense('page');
$book->xownPage[] = $page;
$id = R::store($book);
$book = R::load('book', $id);
asrt(count($book->xownPage), 1);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
R::trash($book);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
$book = R::dispense('book');
$page = R::dispense('page');
$book->xownPage[] = $page;
$id = R::store($book);
$book = R::load('book', $id);
asrt(count($book->xownPage), 1);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
$book->added = 2;
R::store($book);
$book->added = 'added';
R::store($book);
R::trash($book);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
}
示例5: testPlaysNiceWithPreExitsingSchema
/**
* Test integration with pre-existing schemas.
*
* @return void
*/
public function testPlaysNiceWithPreExitsingSchema()
{
$toolbox = R::getToolBox();
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
$a = new AssociationManager($toolbox);
$page = $redbean->dispense("page");
$page->name = "John's page";
$idpage = $redbean->store($page);
$page2 = $redbean->dispense("page");
$page2->name = "John's second page";
$idpage2 = $redbean->store($page2);
$a->associate($page, $page2);
$adapter->exec("ALTER TABLE " . $writer->esc('page') . "\n\t\tCHANGE " . $writer->esc('name') . " " . $writer->esc('name') . "\n\t\tVARCHAR( 254 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL ");
$page = $redbean->dispense("page");
$page->name = "Just Another Page In a Table";
$cols = $writer->getColumns("page");
asrt($cols["name"], "varchar(254)");
//$pdo->SethMode(1);
$redbean->store($page);
pass();
// No crash?
$cols = $writer->getColumns("page");
asrt($cols["name"], "varchar(254)");
//must still be same
}
示例6: testDoesToolboxContainTheTools
/**
* Does the toolbox contain the necessary tools ?
*
* @return void
*/
public function testDoesToolboxContainTheTools()
{
$toolbox = R::getToolBox();
asrt($toolbox->getDatabaseAdapter() instanceof Adapter, TRUE);
asrt($toolbox->getRedBean() instanceof OODB, TRUE);
asrt($toolbox->getWriter() instanceof QueryWriter, TRUE);
}
示例7: testTainted
/**
* Test tainted.
*
* @return void
*/
public function testTainted()
{
testpack('Original Tainted Tests');
$redbean = R::getRedBean();
$spoon = $redbean->dispense("spoon");
asrt($spoon->getMeta("tainted"), TRUE);
$spoon->dirty = "yes";
asrt($spoon->getMeta("tainted"), TRUE);
testpack('Tainted List test');
$note = R::dispense('note');
$note->text = 'abc';
$note->ownNote[] = R::dispense('note')->setAttr('text', 'def');
$id = R::store($note);
$note = R::load('note', $id);
asrt($note->isTainted(), FALSE);
// Shouldn't affect tainted
$note->text;
asrt($note->isTainted(), FALSE);
$note->ownNote;
asrt($note->isTainted(), TRUE);
testpack('Tainted Test Old Value');
$text = $note->old('text');
asrt($text, 'abc');
asrt($note->hasChanged('text'), FALSE);
$note->text = 'xxx';
asrt($note->hasChanged('text'), TRUE);
$text = $note->old('text');
asrt($text, 'abc');
testpack('Tainted Non-exist');
asrt($note->hasChanged('text2'), FALSE);
testpack('Misc Tainted Tests');
$bean = R::dispense('bean');
$bean->hasChanged('prop');
$bean->old('prop');
}
示例8: logout
public function logout()
{
$adminId = $this->app->getSession()->get('adminId');
$sql = "delete from `adminsession` where `admin_id` = '" . $adminId . "'";
R::exec($sql);
$this->app->getSession()->remove('adminId');
}
示例9: testInnoDBIndexLimit
/**
* Test varchar 191 condition.
*
* @return void
*/
public function testInnoDBIndexLimit()
{
R::nuke();
$book = R::dispense('book');
$book->text = 'abcd';
R::store($book);
$columns = R::inspect('book');
asrt(isset($columns['text']), TRUE);
asrt($columns['text'], 'varchar(191)');
$book = $book->fresh();
$book->text = str_repeat('x', 190);
R::store($book);
$columns = R::inspect('book');
asrt(isset($columns['text']), TRUE);
asrt($columns['text'], 'varchar(191)');
$book = $book->fresh();
$book->text = str_repeat('x', 191);
R::store($book);
$columns = R::inspect('book');
asrt(isset($columns['text']), TRUE);
asrt($columns['text'], 'varchar(191)');
$book = $book->fresh();
$book->text = str_repeat('x', 192);
R::store($book);
$columns = R::inspect('book');
asrt(isset($columns['text']), TRUE);
asrt($columns['text'], 'varchar(255)');
}
示例10: uploadImage
public function uploadImage()
{
$error = '';
$uploadedImages = array();
if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
// Find instance
$id = $this->getParam($this->instanceName . '_id');
if (!empty($id)) {
/** @var \RedbeanPHP\SimpleModel $instanceBean */
$instanceBean = R::findOne($this->model(), 'id = ?', array($id));
/** @var \Skully\App\Models\Setting $instance */
$instance = $instanceBean->box();
} else {
$instance = null;
}
try {
$uploadedImages = $this->processUploadedImage($instance, $this->getParam('settingName'));
} catch (\Exception $e) {
$error = $e->getMessage();
}
}
if (!empty($error)) {
echo json_encode(array('error' => $error));
} else {
echo json_encode($uploadedImages);
}
}
示例11: testDump
/**
* Test dump().
*
* @return void
*/
public function testDump()
{
$beans = R::dispense('bean', 2);
$beans[0]->name = 'hello';
$beans[1]->name = 'world';
$array = R::dump($beans);
asrt(is_array($array), TRUE);
foreach ($array as $item) {
asrt(is_string($item), TRUE);
}
$beans[1]->name = 'world, and a very long string that should be shortened';
$array = R::dump($beans);
asrt(is_array($array), TRUE);
asrt(strpos($array[1], '...'), 35);
//just to get 100% test cov, we dont need to test this
dmp($beans);
pass();
//test wrong input
asrt(is_array(R::dump(NULL)), TRUE);
asrt(count(R::dump(NULL)), 0);
asrt(is_array(R::dump('')), TRUE);
asrt(count(R::dump('')), 0);
asrt(is_array(R::dump(1)), TRUE);
asrt(count(R::dump(1)), 0);
asrt(is_array(R::dump(TRUE)), TRUE);
asrt(count(R::dump(FALSE)), 0);
}
示例12: testDisableVoteIdea
public function testDisableVoteIdea()
{
Scripts::LoginUser('newemail2@phpback.org', 'Gates123');
$this->url('home/profile/4');
$this->byLinkText('Delete votes')->click();
$voteidea = RedBean::load('ideas', 3);
$this->assertEquals($voteidea->votes, '0');
}
示例13: testBasicBox
/**
* Test boxing.
*
* @return void
*/
public function testBasicBox()
{
$soup = R::dispense('soup');
$soup->flavour = 'tomato';
$this->giveMeSoup($soup->box());
$this->giveMeBean($soup->box()->unbox());
$this->giveMeBean($soup);
}
示例14: testTwoWordsUnderscoredBean
/**
* Cant have underscored beans
* @expectedException \RedBeanPHP\RedException
*/
public function testTwoWordsUnderscoredBean()
{
R::freeze(false);
$testName = R::dispense('test_name');
$id = R::store($testName);
R::load('test_name', $id);
R::freeze($this->frozen);
}
示例15: testCreateAdmin
public function testCreateAdmin()
{
$this->migrate();
$admin = $this->app->createModel('admin', array('name' => 'Admin', 'email' => 'admin@skullyframework.com', 'password' => 'lepass', 'password_confirmation' => 'lepass', 'status' => Admin::STATUS_ACTIVE));
R::store($admin);
$bean = R::findOne('admin', 'name = ?', array('Admin'));
$this->assertEquals($bean->name, $admin->get('name'));
}