本文整理汇总了PHP中R::getColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP R::getColumns方法的具体用法?PHP R::getColumns怎么用?PHP R::getColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::getColumns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWideningColumnForConstraint
/**
* Test widen for constraint.
*
* @return void
*/
public function testWideningColumnForConstraint()
{
testpack('widening column for constraint');
$bean1 = R::dispense('project');
$bean2 = R::dispense('invoice');
R::setStrictTyping(FALSE);
$bean3 = R::dispense('invoice_project');
R::setStrictTyping(TRUE);
$bean3->project_id = 1;
$bean3->invoice_id = 2;
R::store($bean3);
$cols = R::getColumns('invoice_project');
asrt($cols['project_id'], "tinyint(1) unsigned");
asrt($cols['invoice_id'], "tinyint(3) unsigned");
R::$writer->addConstraint($bean1, $bean2);
$cols = R::getColumns('invoice_project');
asrt($cols['project_id'], "int(11) unsigned");
asrt($cols['invoice_id'], "int(11) unsigned");
}
示例2: testTypesDateTimes
/**
* Datetime.
*
* @return void
*/
public function testTypesDateTimes()
{
$bean = R::dispense('bean');
$bean->date = '2011-10-10 10:00:00';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['date'], 'DATE');
R::nuke();
$bean = R::dispense('bean');
$bean->date = '2011-10-10 10:00';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['date'], 'DATE');
R::nuke();
$bean = R::dispense('bean');
$bean->date = '2011-10-10 10:00:20.99';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['date'], 'TIMESTAMP(6)');
try {
$bean = R::dispense('bean');
$bean->title = 123;
$bean->setMeta('cast.title', 'invalid');
R::store($bean);
fail();
} catch (RedBean_Exception $e) {
pass();
} catch (Exception $e) {
fail();
}
$bean = R::dispense('bean');
$bean->title = 123;
$bean->setMeta('cast.title', 'NVARCHAR2(255)');
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['title'], 'NVARCHAR2(255)');
R::nuke();
$bean = R::dispense('bean');
$bean->title = 123;
$bean->setMeta('cast.title', 'string');
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['title'], 'NVARCHAR2(255)');
}
示例3: testTypesStrings
/**
* Test types of strings.
*
* @return void
*/
public function testTypesStrings()
{
$bean = R::dispense('bean');
$bean->data = 'abcdefghijk';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['data'], 'text');
$bean = R::load('bean', $bean->id);
asrt($bean->data, 'abcdefghijk');
$bean->data = '(1,2)';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['data'], 'text');
$bean->data = '[(1.2,1.4),(2.2,34)]';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['data'], 'text');
$bean->data = '<(9.2,1.2),7.9>';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['data'], 'text');
$bean->data = '$25';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['data'], 'text');
$bean->data = '2012-10-10 10:00:00';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['data'], 'text');
}
示例4: testSpecialDataTypes
/**
* Test special data types.
*
* @return void
*/
public function testSpecialDataTypes()
{
testpack('Special data types');
$bean = R::dispense('bean');
$bean->date = 'someday';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['date'], 'TEXT');
$bean = R::dispense('bean');
$bean->date = '2011-10-10';
R::nuke();
$bean = R::dispense('bean');
$bean->date = '2011-10-10';
R::store($bean);
$cols = R::getColumns('bean');
asrt($cols['date'], 'NUMERIC');
}
示例5: testScenarios
//.........这里部分代码省略.........
asrt(R::load('page', 5)->book->title, 'abc');
asrt(R::load('page', 3)->book->title, 'abc');
// Add the other way around - single bean
$page1->id = 0;
$page1->book = $book2;
$page1 = R::load('page', R::store($page1));
asrt($page1->book->title, 'def');
$b2 = R::load('book', $id);
asrt(count($b2->ownPage), 2);
// Remove the other way around - single bean
unset($page1->book);
R::store($page1);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 0);
// Re-add the page
$b2->ownPage[] = $page1;
R::store($b2);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 1);
// Different, less elegant way to remove
$page1 = reset($b2->ownPage);
$page1->book_id = NULL;
R::store($page1);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 0);
// Re-add the page
$b2->ownPage[] = $page1;
R::store($b2);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 1);
// Another less elegant way to remove
$page1->book = NULL;
R::store($page1);
$cols = R::getColumns('page');
asrt(isset($cols['book']), FALSE);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 0);
// Re-add the page
$b2->ownPage[] = $page1;
R::store($b2);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 1);
// Another less elegant... just plain ugly... way to remove
$page1->book = FALSE;
R::store($page1);
$cols = R::getColumns('page');
asrt(isset($cols['book']), FALSE);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 0);
// Re-add the page
$b2->ownPage[] = $page1;
R::store($b2);
$b2 = R::load('book', $book2->id);
asrt(count($b2->ownPage), 1);
// You are not allowed to re-use the field for something else
foreach (array(1, -2.1, array(), TRUE, 'NULL', new stdClass(), 'just a string', array('a' => 1), 0) as $value) {
try {
$page1->book = $value;
fail();
} catch (RedBean_Exception_Security $e) {
pass();
}
}
// Test fk, not allowed to set to 0
$page1 = reset($b2->ownPage);
$page1->book_id = 0;