本文整理汇总了PHP中RedBeanPHP\Facade::getWriter方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::getWriter方法的具体用法?PHP Facade::getWriter怎么用?PHP Facade::getWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::getWriter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testChill
/**
* Test Chill mode.
*
* @return void
*/
public function testChill()
{
$bean = R::dispense('bean');
$bean->col1 = '1';
$bean->col2 = '2';
R::store($bean);
asrt(count(R::getWriter()->getColumns('bean')), 3);
$bean->col3 = '3';
R::store($bean);
asrt(count(R::getWriter()->getColumns('bean')), 4);
R::freeze(array('umbrella'));
$bean->col4 = '4';
R::store($bean);
asrt(count(R::getWriter()->getColumns('bean')), 5);
R::freeze(array('bean'));
$bean->col5 = '5';
try {
R::store($bean);
fail();
} catch (\Exception $e) {
pass();
}
asrt(count(R::getWriter()->getColumns('bean')), 5);
R::freeze(array());
$bean->col5 = '5';
R::store($bean);
asrt(count(R::getWriter()->getColumns('bean')), 6);
}
示例2: testNuke
/**
* Nuclear test suite.
*
* @return void
*/
public function testNuke()
{
$bean = R::dispense('bean');
R::store($bean);
asrt(count(R::getWriter()->getTables()), 1);
R::nuke();
asrt(count(R::getWriter()->getTables()), 0);
$bean = R::dispense('bean');
R::store($bean);
asrt(count(R::getWriter()->getTables()), 1);
R::freeze();
R::nuke();
// No effect
asrt(count(R::getWriter()->getTables()), 1);
R::freeze(FALSE);
}
示例3: testGlue
/**
* Tests whether we can intelligently glue together SQL snippets.
*
* @return void
*/
public function testGlue()
{
$writer = R::getWriter();
//Can we add a condition without having to type 'WHERE' - usual suspects
asrt($writer->glueSQLCondition(' name = ? '), ' WHERE name = ? ');
asrt($writer->glueSQLCondition(' value1 > ? OR value < ? '), ' WHERE value1 > ? OR value < ? ');
//Does it recognize NON-WHERE conditions? - usual suspects
asrt($writer->glueSQLCondition(' ORDER BY name '), ' ORDER BY name ');
asrt($writer->glueSQLCondition(' LIMIT 10 '), ' LIMIT 10 ');
asrt($writer->glueSQLCondition(' OFFSET 20 '), ' OFFSET 20 ');
//highly doubtful but who knows... - I think nobody will ever use this in a query snippet.
asrt($writer->glueSQLCondition(' GROUP BY grp '), ' GROUP BY grp ');
asrt($writer->glueSQLCondition(' HAVING x = ? '), ' HAVING x = ? ');
//can we replace WHERE with AND ?
asrt($writer->glueSQLCondition(' AND name = ? ', QueryWriter::C_GLUE_WHERE), ' WHERE name = ? ');
//can we glue with AND instead of WHERE ?
asrt($writer->glueSQLCondition(' value1 > ? OR value < ? ', QueryWriter::C_GLUE_AND), ' AND value1 > ? OR value < ? ');
//non-cases
asrt($writer->glueSQLCondition(' GROUP BY grp ', QueryWriter::C_GLUE_WHERE), ' GROUP BY grp ');
asrt($writer->glueSQLCondition(' GROUP BY grp ', QueryWriter::C_GLUE_AND), ' GROUP BY grp ');
}
示例4: testAddingIndex
/**
* Test whether we can manually create indexes.
*
* @return void
*/
public function testAddingIndex()
{
R::nuke();
$sql = '
CREATE TABLE song (
id INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT,
album_id INT( 11 ) UNSIGNED NOT NULL,
category VARCHAR( 255 ),
PRIMARY KEY ( id )
)
ENGINE = InnoDB
';
R::exec($sql);
$sql = 'SHOW INDEX FROM song';
$indexes = R::getAll($sql);
asrt(count($indexes), 1);
asrt($indexes[0]['Table'], 'song');
asrt($indexes[0]['Key_name'], 'PRIMARY');
$writer = R::getWriter();
$writer->addIndex('song', 'index1', 'album_id');
$indexes = R::getAll('SHOW INDEX FROM song');
asrt(count($indexes), 2);
asrt($indexes[0]['Table'], 'song');
asrt($indexes[0]['Key_name'], 'PRIMARY');
asrt($indexes[1]['Table'], 'song');
asrt($indexes[1]['Key_name'], 'index1');
//Cant add the same index twice
$writer->addIndex('song', 'index2', 'category');
$indexes = R::getAll('SHOW INDEX FROM song');
asrt(count($indexes), 3);
//Dont fail, just dont
try {
$writer->addIndex('song', 'index3', 'nonexistant');
pass();
} catch (\Exception $e) {
fail();
}
asrt(count($indexes), 3);
try {
$writer->addIndex('nonexistant', 'index4', 'nonexistant');
pass();
} catch (\Exception $e) {
fail();
}
asrt(count($indexes), 3);
try {
$writer->addIndex('nonexistant', '', 'nonexistant');
pass();
} catch (\Exception $e) {
fail();
}
asrt(count($indexes), 3);
}
示例5: testMultiDeleteUpdate
/**
* Test trashAll().
*/
public function testMultiDeleteUpdate()
{
testpack('test multi delete and multi update');
$beans = R::dispenseLabels('bean', array('a', 'b'));
$ids = R::storeAll($beans);
asrt((int) R::count('bean'), 2);
R::trashAll(R::batch('bean', $ids));
asrt((int) R::count('bean'), 0);
testpack('test assocManager check');
$rb = new OODB(R::getWriter());
try {
$rb->getAssociationManager();
fail();
} catch (RedException $e) {
pass();
}
}
示例6: testFKInspect
/**
* Tests foreign keys but checks using ProxyWriter.
*
* @return void
*/
public function testFKInspect()
{
$faultyWriter = new \FaultyWriter(R::getDatabaseAdapter());
try {
$null = \ProxyWriter::callMethod($faultyWriter, 'getForeignKeyForTypeProperty', 'test', 'test');
pass();
} catch (\Exception $e) {
fail();
}
asrt(is_null($null), TRUE);
$writer = R::getWriter();
R::nuke();
$book = R::dispense('book');
$page = R::dispense('page');
$book->xownPage[] = $page;
R::store($book);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'page', 'book_id');
asrt(is_array($keys), TRUE);
asrt($keys['on_delete'], 'CASCADE');
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'page', 'id');
asrt(is_null($keys), TRUE);
R::nuke();
$book = R::dispense('book');
$page = R::dispense('page');
$book->ownPage[] = $page;
R::store($book);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'page', 'book_id');
asrt(is_array($keys), TRUE);
asrt($keys['on_delete'], 'SET NULL');
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'page', 'id');
asrt(is_null($keys), TRUE);
R::nuke();
$book = R::dispense('book');
$page = R::dispense('page');
$book->alias('magazine')->xownPage[] = $page;
R::store($book);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'page', 'magazine_id');
asrt(is_array($keys), TRUE);
asrt($keys['on_delete'], 'CASCADE');
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'page', 'book_id');
asrt(is_null($keys), TRUE);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'page', 'id');
asrt(is_null($keys), TRUE);
R::nuke();
$book = R::dispense('book');
$page = R::dispense('page');
$book->cover = $page;
R::store($book);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'book', 'cover_id');
asrt(is_array($keys), TRUE);
asrt($keys['on_delete'], 'SET NULL');
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'book', 'page_id');
asrt(is_null($keys), TRUE);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'book', 'id');
asrt(is_null($keys), TRUE);
R::nuke();
$book = R::dispense('book');
$category = R::dispense('category');
$book->sharedTag[] = $category;
R::store($book);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'book_category', 'book_id');
asrt(is_array($keys), TRUE);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'book_category', 'category_id');
asrt(is_array($keys), TRUE);
$keys = \ProxyWriter::callMethod($writer, 'getForeignKeyForTypeProperty', 'book_category', 'id');
asrt(is_null($keys), TRUE);
}
示例7: testCommonUsageFacade
/**
* Test common Facade usage scenarios.
*
* @return void
*/
public function testCommonUsageFacade()
{
$toolbox = R::getToolBox();
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
$a = new AssociationManager($toolbox);
asrt(R::getRedBean() instanceof OODB, TRUE);
asrt(R::getToolBox() instanceof ToolBox, TRUE);
asrt(R::getDatabaseAdapter() instanceof Adapter, TRUE);
asrt(R::getWriter() instanceof QueryWriter, TRUE);
$book = R::dispense("book");
asrt($book instanceof OODBBean, TRUE);
$book->title = "a nice book";
$id = R::store($book);
asrt($id > 0, TRUE);
$book = R::load("book", (int) $id);
asrt($book->title, "a nice book");
asrt(R::load('book', 999)->title, NULL);
R::freeze(TRUE);
try {
R::load('bookies', 999);
fail();
} catch (\Exception $e) {
pass();
}
R::freeze(FALSE);
$author = R::dispense("author");
$author->name = "me";
R::store($author);
$book9 = R::dispense("book");
$author9 = R::dispense("author");
$author9->name = "mr Nine";
$a9 = R::store($author9);
$book9->author_id = $a9;
$bk9 = R::store($book9);
$book9 = R::load("book", $bk9);
$author = R::load("author", $book9->author_id);
asrt($author->name, "mr Nine");
R::trash($author);
R::trash($book9);
pass();
$book2 = R::dispense("book");
$book2->title = "second";
R::store($book2);
$book3 = R::dispense("book");
$book3->title = "third";
R::store($book3);
asrt(count(R::find("book")), 3);
asrt(count(R::findAll("book")), 3);
asrt(count(R::findAll("book", " LIMIT 2")), 2);
asrt(count(R::find("book", " id=id ")), 3);
asrt(count(R::find("book", " title LIKE ?", array("third"))), 1);
asrt(count(R::find("book", " title LIKE ?", array("%d%"))), 2);
// Find without where clause
asrt(count(R::findAll('book', ' order by id')), 3);
R::trash($book3);
R::trash($book2);
asrt(count(R::getAll("SELECT * FROM book ")), 1);
asrt(count(R::getCol("SELECT title FROM book ")), 1);
asrt((int) R::getCell("SELECT 123 "), 123);
$book = R::dispense("book");
$book->title = "not so original title";
$author = R::dispense("author");
$author->name = "Bobby";
R::store($book);
$aid = R::store($author);
$author = R::findOne("author", " name = ? ", array("Bobby"));
}
示例8: testUpdatingBeans
/**
* All kinds of tests for basic CRUD.
*
* Does the data survive?
*
* @return void
*/
public function testUpdatingBeans()
{
testpack('Test basic support UUID/override ID default value');
$bean = R::dispense('bean');
R::store($bean);
if ($this->currentlyActiveDriverID === 'mysql') {
//otherwise UTF8 causes index overflow in mysql: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
R::exec('alter table bean modify column id char(3);');
} else {
R::getWriter()->widenColumn('bean', 'id', R::getWriter()->scanType('abc'));
}
$bean->id = 'abc';
R::store($bean);
asrt($bean->id, 'abc');
testpack('Test Update');
try {
R::store(array());
fail();
} catch (RedException $e) {
pass();
}
$toolbox = R::getToolBox();
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
$page = $redbean->dispense("page");
$page->name = "old name";
$id = $redbean->store($page);
asrt($page->getMeta('tainted'), FALSE);
$page->setAttr('name', "new name");
asrt($page->getMeta('tainted'), TRUE);
$id = $redbean->store($page);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
// Null should == NULL after saving
$page->rating = NULL;
$newid = $redbean->store($page);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
asrt($page->rating === NULL, TRUE);
asrt(!$page->rating, TRUE);
$page->rating = FALSE;
$newid = $redbean->store($page);
asrt($newid, $id);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
asrt((bool) $page->rating, FALSE);
asrt($page->rating == FALSE, TRUE);
asrt(!$page->rating, TRUE);
$page->rating = TRUE;
$newid = $redbean->store($page);
asrt($newid, $id);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
asrt((bool) $page->rating, TRUE);
asrt($page->rating == TRUE, TRUE);
asrt($page->rating == TRUE, TRUE);
$page->rating = NULL;
R::store($page);
$page = R::load('page', $page->id);
asrt($page->rating, NULL);
$page->rating = "1";
$newid = $redbean->store($page);
asrt($newid, $id);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
asrt($page->rating, "1");
$page->rating = "0";
$newid = $redbean->store($page);
asrt($page->rating, "0");
$page->rating = 0;
$newid = $redbean->store($page);
asrt($page->rating, 0);
$page->rating = "0";
$newid = $redbean->store($page);
asrt($newid, $id);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
asrt(!$page->rating, TRUE);
asrt($page->rating == 0, TRUE);
asrt($page->rating == FALSE, TRUE);
$page->rating = 5;
$newid = $redbean->store($page);
asrt($newid, $id);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
asrt(strval($page->rating), "5");
$page->rating = 300;
$newid = $redbean->store($page);
asrt($newid, $id);
$page = $redbean->load("page", $id);
asrt($page->name, "new name");
//.........这里部分代码省略.........
示例9: testSingleColUniqueConstraint
/**
* Test single column bases unique constraints.
*
* @return void
*/
public function testSingleColUniqueConstraint()
{
testpack('Testing unique constraint on single column');
$book = R::dispense('book');
$book->title = 'bla';
$book->extra = 2;
$id = R::store($book);
R::getWriter()->addUniqueIndex('book', array('title'));
$book = R::dispense('book');
$book->title = 'bla';
$expected = NULL;
try {
R::store($book);
fail();
} catch (SQL $e) {
$expected = $e;
}
asrt($expected instanceof SQL, TRUE);
asrt(R::count('book'), 1);
$book = R::load('book', $id);
// Causes failure, table will be rebuild
$book->extra = 'CHANGE';
$id2 = R::store($book);
$book2 = R::load('book', $id2);
$book = R::dispense('book');
$book->title = 'bla';
try {
R::store($book);
fail();
} catch (SQL $e) {
$expected = $e;
}
asrt($expected instanceof SQL, TRUE);
asrt(R::count('book'), 1);
}
示例10: testIndexCreationFail
/**
* Tests index fails.
*
* @return void
*/
public function testIndexCreationFail()
{
R::nuke();
$book = R::dispense('book');
$book->author_id = 'a';
R::store($book);
$indexes = getIndexes('book');
//should just work fine
asrt(in_array('index_foreignkey_book_author', $indexes), TRUE);
//these should just pass, no indexes but no errors as well
R::getWriter()->addIndex('book', 'bla', 'nonexist');
pass();
R::getWriter()->addIndex('book', '@#$', 'nonexist');
pass();
R::getWriter()->addIndex('nonexist', 'bla', 'nonexist');
pass();
$indexesAfter = getIndexes('book');
asrt(count($indexesAfter), count($indexes));
}
示例11: testAddingIndex
/**
* Test whether we can manually create indexes.
*
* @return void
*/
public function testAddingIndex()
{
R::nuke();
$sql = 'CREATE TABLE song (
id INTEGER PRIMARY KEY AUTOINCREMENT,
album_id INTEGER,
category TEXT
) ';
R::exec($sql);
$writer = R::getWriter();
$indexes = R::getAll('PRAGMA index_list("song") ');
asrt(count($indexes), 0);
$writer->addIndex('song', 'index1', 'album_id');
$indexes = R::getAll('PRAGMA index_list("song") ');
asrt(count($indexes), 1);
$writer->addIndex('song', 'index1', 'album_id');
$indexes = R::getAll('PRAGMA index_list("song") ');
asrt(count($indexes), 1);
$writer->addIndex('song', 'index2', 'category');
$indexes = R::getAll('PRAGMA index_list("song") ');
asrt(count($indexes), 2);
try {
$writer->addIndex('song', 'index1', 'nonexistant');
pass();
} catch (\Exception $ex) {
fail();
}
$indexes = R::getAll('PRAGMA index_list("song") ');
asrt(count($indexes), 2);
try {
$writer->addIndex('nonexistant', 'index1', 'nonexistant');
pass();
} catch (\Exception $ex) {
fail();
}
$indexes = R::getAll('PRAGMA index_list("song") ');
asrt(count($indexes), 2);
}
示例12: testSelects
/**
* Test selecting.
*
* @return void
*/
public function testSelects()
{
$rooms = R::dispense('room', 2);
$rooms[0]->kind = 'suite';
$rooms[1]->kind = 'classic';
$rooms[0]->number = 6;
$rooms[1]->number = 7;
R::store($rooms[0]);
R::store($rooms[1]);
$rooms = R::getAssoc('SELECT * FROM room WHERE id < -999');
asrt(is_array($rooms), TRUE);
asrt(count($rooms), 0);
$rooms = R::getAssoc('SELECT ' . R::getWriter()->esc('number') . ', kind FROM room ORDER BY kind ASC');
foreach ($rooms as $key => $room) {
asrt($key === 6 || $key === 7, TRUE);
asrt($room == 'classic' || $room == 'suite', TRUE);
}
$rooms = R::getDatabaseAdapter()->getAssoc('SELECT kind FROM room');
foreach ($rooms as $key => $room) {
asrt($room == 'classic' || $room == 'suite', TRUE);
asrt($room, $key);
}
$rooms = R::getAssoc('SELECT `number`, kind FROM rooms2 ORDER BY kind ASC');
asrt(count($rooms), 0);
asrt(is_array($rooms), TRUE);
// GetCell should return NULL in case of exception
asrt(NULL, R::getCell('SELECT dream FROM fantasy'));
}
示例13: testCreationOfLinkTable
/**
* Test creation of link table.
*
* @return void
*/
public function testCreationOfLinkTable()
{
asrt(in_array('consult', R::getWriter()->getTables()), FALSE);
$d = R::dispense('doctor')->setAttr('name', 'd1');
$p = R::dispense('patient')->setAttr('name', 'p1');
$d->sharedPatient[] = $p;
R::store($d);
asrt(in_array('consult', R::getWriter()->getTables()), TRUE);
}
示例14: ExportWithFilters
/**
* Test exporting with filters.
*
* @return void
*/
public function ExportWithFilters()
{
testpack('Export with filters');
$book = R::dispense('book');
$pages = R::dispense('page', 2);
$texts = R::dispense('text', 2);
$images = R::dispense('image', 2);
$author = R::dispense('author');
$pub = R::dispense('publisher');
$bookmarks = R::dispense('bookmark', 2);
$pages[0]->ownText = array($texts[0]);
$pages[0]->ownImage = array($images[0]);
$pages[1]->ownText = array($texts[1]);
$pages[1]->ownImage = array($images[1]);
$pages[0]->sharedBookmark[] = $bookmarks[0];
$pages[1]->sharedBookmark[] = $bookmarks[1];
$bookmarks[0]->ownNote[] = R::dispense('note')->setAttr('text', 'a note');
$bookmarks[1]->ownNote[] = R::dispense('note')->setAttr('text', 'a note');
$book->ownPage = $pages;
$book->author = $author;
$author->publisher = $pub;
$bookID = R::store($book);
R::getDuplicationManager()->setTables(R::getWriter()->getTables());
$objects = R::exportAll(array($book), TRUE, array());
asrt(isset($objects[0]['ownPage']), TRUE);
asrt(count($objects[0]['ownPage']), 2);
asrt(isset($objects[0]['author']), TRUE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
asrt(isset($objects[0]['ownPage'][0]['ownImage']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownImage']), 1);
$objects = R::exportAll(array($book), TRUE, array('page', 'author', 'text', 'image'));
asrt(isset($objects[0]['ownPage']), TRUE);
asrt(count($objects[0]['ownPage']), 2);
asrt(isset($objects[0]['author']), TRUE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
asrt(isset($objects[0]['ownPage'][0]['ownImage']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownImage']), 1);
$objects = R::exportAll(array($book), TRUE, 'author');
asrt(isset($objects[0]['ownPage']), FALSE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), FALSE);
$objects = R::exportAll(array($book), TRUE, array('page'));
asrt(isset($objects[0]['author']), FALSE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), FALSE);
$objects = R::exportAll(array($book), TRUE, array('page', 'text'));
asrt(isset($objects[0]['author']), FALSE);
asrt(isset($objects[0]['ownPage']), TRUE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
asrt(isset($objects[0]['ownPage'][0]['ownImage']), FALSE);
$objects = R::exportAll(array($book), TRUE, array('none'));
asrt(isset($objects[0]['author']), FALSE);
asrt(isset($objects[0]['ownPage']), FALSE);
$texts = R::find('text');
R::getDuplicationManager()->setCacheTables(FALSE);
testpack('Keyless export');
$book = R::load('book', $bookID);
$book->ownPage;
$export = $book->export();
asrt(isset($export['ownPage'][0]), TRUE);
}
示例15: testAddingIndex
/**
* Test whether we can manually create indexes.
*
* @return void
*/
public function testAddingIndex()
{
R::nuke();
$sql = 'CREATE TABLE song (
id SERIAL PRIMARY KEY,
album_id INTEGER,
category VARCHAR(255)
)';
R::exec($sql);
$indexes = R::getAll(" SELECT * FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'song' ");
asrt(count($indexes), 1);
$writer = R::getWriter();
$writer->addIndex('song', 'index1', 'album_id');
$indexes = R::getAll(" SELECT * FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'song' ");
asrt(count($indexes), 2);
//Cant add the same index twice
$writer->addIndex('song', 'index1', 'album_id');
$indexes = R::getAll(" SELECT * FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'song' ");
asrt(count($indexes), 2);
$writer->addIndex('song', 'index2', 'category');
$indexes = R::getAll(" SELECT * FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'song' ");
asrt(count($indexes), 3);
//Dont fail, just dont
try {
$writer->addIndex('song', 'index3', 'nonexistant');
pass();
} catch (\Exception $e) {
fail();
}
$indexes = R::getAll(" SELECT * FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'song' ");
asrt(count($indexes), 3);
try {
$writer->addIndex('nonexistant', 'index4', 'nonexistant');
pass();
} catch (\Exception $e) {
fail();
}
$indexes = R::getAll(" SELECT * FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'song' ");
asrt(count($indexes), 3);
}