本文整理汇总了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');
}