本文整理匯總了PHP中RedBeanPHP\Facade::flat方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facade::flat方法的具體用法?PHP Facade::flat怎麽用?PHP Facade::flat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::flat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array_flatten
function array_flatten($array)
{
return \RedBeanPHP\Facade::flat($array);
}
示例2: testINClause
/**
* Test forming IN-clause using genSlots and flat.
*
* @return void
*/
public function testINClause()
{
list($flowers, $shop) = R::dispenseAll('flower*4,shop');
$flowers[0]->color = 'red';
$flowers[1]->color = 'yellow';
$flowers[2]->color = 'blue';
$flowers[3]->color = 'purple';
$flowers[0]->price = 10;
$flowers[1]->price = 15;
$flowers[2]->price = 20;
$flowers[3]->price = 25;
$shop->xownFlowerList = $flowers;
R::store($shop);
$colors = array('red', 'yellow');
$result = $this->getColors(R::find('flower', ' color IN (' . R::genSlots($colors) . ' ) AND price < ?', R::flat(array($colors, 100))));
asrt($result, 'red,yellow');
$colors = array('red', 'yellow');
$result = $this->getColors(R::find('flower', ' color IN (' . R::genSlots($colors) . ' ) AND price < ?', R::flat(array($colors, 10))));
asrt($result, '');
$colors = array('red', 'yellow');
$result = $this->getColors(R::find('flower', ' color IN (' . R::genSlots($colors) . ' ) AND price < ?', R::flat(array($colors, 15))));
asrt($result, 'red');
asrt(json_encode(R::flat(array('a', 'b', 'c'))), '["a","b","c"]');
asrt(json_encode(R::flat(array('a', array('b'), 'c'))), '["a","b","c"]');
asrt(json_encode(R::flat(array('a', array('b', array('c'))))), '["a","b","c"]');
asrt(json_encode(R::flat(array(array('a', array('b', array(array('c'))))))), '["a","b","c"]');
asrt(json_encode(R::flat(array('a', 'b', 'c', array()))), '["a","b","c"]');
asrt(genslots(array(1, 2)), '?,?');
asrt(json_encode(array_flatten(array(array('a', array('b', array(array('c'))))))), '["a","b","c"]');
asrt(genslots(array(1, 2), 'IN (%s) AND'), 'IN (?,?) AND');
asrt(genslots(array(), ' IN (%s) AND '), '');
$colors = array('blue', 'purple', 'red');
$flowers = R::find('flower', genslots($colors, ' color IN (%s) AND ') . ' price > ? ', array_flatten(array($colors, 11)));
asrt($this->getColors($flowers), 'blue,purple');
$flowers = R::find('flower', genslots(array(), ' color IN (%s) AND ') . ' price > ? ', array_flatten(array(array(), 11)));
asrt($this->getColors($flowers), 'blue,purple,yellow');
$flowers = R::find('flower', ' id > 0 AND ' . genslots($colors, ' color IN (%s) AND ') . ' price > ? ', array_flatten(array($colors, 11)));
asrt($this->getColors($flowers), 'blue,purple');
$flowers = R::find('flower', ' id > 0 AND ' . genslots(array(), ' color IN (%s) AND ') . ' price > ? ', array_flatten(array(array(), 11)));
asrt($this->getColors($flowers), 'blue,purple,yellow');
}