本文整理汇总了PHP中iterFirst函数的典型用法代码示例。如果您正苦于以下问题:PHP iterFirst函数的具体用法?PHP iterFirst怎么用?PHP iterFirst使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了iterFirst函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadScriptByName
/**
* Loads script by name
*
* @param string $name Script name
* @return RM_ReportScript_iScript
*/
public function loadScriptByName($name)
{
if (!$name) {
return M('Base')->null();
}
return iterFirst($this->storage('script')->getObjectList()->filter('name=?', $name));
}
示例2: mergeLeaves
/**
* Merges and saves leaves (объединить пересекающиеся отпуска).
*
* @return bool
*/
public function mergeLeaves()
{
$request = $this->getLeaveIntersections();
if ($request->count() > 0) {
$request1 = clone $request;
$minObLeave = iterFirst($request->sort('date_from', 'ASC'));
$maxObLeave = iterFirst($request1->sort('date_to', 'DESC'));
$update_arr = array();
if (strtotime($minObLeave->date_from) < strtotime($this->date_from)) {
$update_arr['date_from'] = $minObLeave->date_from;
}
if (strtotime($maxObLeave->date_to) > strtotime($this->date_to)) {
$update_arr['date_to'] = $maxObLeave->date_to;
}
unset($request1);
// сначала надо удалить старые отпуска
$deleted_leaves = array();
foreach ($request as $item) {
$deleted_leaves[$item->id()] = $item;
$item->delete();
}
// обновить даты начала и окончания отпуска
$this->update($update_arr);
// вернуть массив id удаленных отпусков
return $deleted_leaves;
}
return FALSE;
}
示例3: process
public function process(array $data, $field, RM_Base_iResult $result)
{
if (!isNull(iterFirst(M('Category')->getCategoryList()->filter('name=? and id!=?', $data[$field], $data['id'])))) {
$result->error('name_not_unique', $field);
return FALSE;
}
return TRUE;
}
示例4: searchValueIntoAttribute
public function searchValueIntoAttribute(RM_Gpc_Attribute_Object $obAttribute, $value_name)
{
$obValue = M('Base')->null();
foreach (M('Gpc')->getValueList()->filter(L(NULL) . '_name = ?', $value_name)->sort('id', 'DESC') as $obValue) {
if (!isNull(iterFirst($obAttribute->getValues()->filter('id = ?', $obValue->id())->sort('id')))) {
break;
}
}
return $obValue;
}
示例5: execute
/**
* @see RM_Holder_Invoice_item_State::execute()
*/
public function execute()
{
$obInvoice = $this->_getExistsInvoiceOrCreate();
$obInvoice->addEntity($this->_obItem->getEntity());
$newItem = iterFirst($obInvoice->getItemsList()->filter('entity_id = ?', $this->_obItem->entity_id));
$newItem->addDescription('Недостающая часть для накладной №' . $this->_obItem->getInvoice()->number);
$newItem->save();
$this->_obItem->addDescription('Недостающая часть в накладной №' . $obInvoice->number);
$this->_obItem->save();
}
示例6: getSizeAsString
/**
* Enter description here...
*
* @return string
*/
public function getSizeAsString()
{
$type = M('User')->getPetNameByAnimalType($this->_obFamily->animal_type);
if (in_array($type, array('cat', 'dog'))) {
if (!isNull($obj = iterFirst(M('Store')->requestQuery(M('Store')->factoryObject(), M('Db')->createQuery(M('user')->table($type . '_size'))->what('*')->where('id = ?', $this->_obFamily->animal_weight_id))))) {
return $obj->name;
}
}
return '';
}
示例7: execute
/**
* @see RM_Holder_Invoice_Item_State::execute()
*/
public function execute()
{
$this->_obItem->changeState(RM_Holder_Invoice_Item_State::KIT);
$obBackInvoice = $this->_getExistsInvoiceOrCreate(RM_Holder_Invoice_Item_State::BACK);
$obBackInvoice->addEntity($this->_obItem->getEntity());
$backItem = iterFirst($obBackInvoice->getItemsList()->filter('entity_id = ?', $this->_obItem->entity_id));
$obOldInvoice = $this->_obItem->getInvoice();
$backItem->descr .= 'Возврат из накладной №' . $obOldInvoice->number;
$backItem->save();
return TRUE;
}
示例8: process
public function process(array $data, $field, RM_Base_iResult $result)
{
$iterator = M('Purchase')->getPurchaseList()->filter('user_id=? and bdate=? and check_id=? and is_deleted=0 and shop_id!=?', $data['user_id'], $data['bdate'], $data['check_id'], $data['shop_id']);
if ($data['id']) {
$iterator->filter('id!=?', $data['id']);
}
if ($data['shop_id'] < 1 || isNull(iterFirst($iterator))) {
return TRUE;
}
$result->error('shop_not_the_same', $field);
return FALSE;
}
示例9: process
public function process(array $data, $field, RM_Base_iResult $result)
{
$search = M('Purchase')->getPurchaseList()->filter('user_id=? and bdate=? and receipt_id=? and is_deleted=0 and barcode_value=?', $data['user_id'], $data['bdate'], $data['receipt_id'], $data['barcode_value']);
if ($data['id']) {
$search->filter('id!=?', $data['id']);
}
if ($data['is_deleted'] == 1 || isNull(iterFirst($search))) {
return TRUE;
}
$result->error('barcode_not_unique', $field);
return FALSE;
}
示例10: process
public function process(RM_Points_Action $obAction = NULL)
{
$params = $obAction->getParams();
$obAccount = $this->getAccount($params['user_id']);
$obPayment = iterFirst($obAccount->getPaymentList()->filter('event=? and amount_date=? and vocation_end=?', 'leave-add', $params['prevFrom'], $params['prevTo']));
if (isNull($obPayment)) {
return TRUE;
}
$obPayment->amount_date = $params['from'];
$obPayment->vocation_end = $params['to'];
return $obPayment->save();
}
示例11: countAgain
public function countAgain()
{
$barcode = MC('AveragePrice')->getBarcodeValue();
$obQuery = MC('AveragePrice')->getQuery($barcode);
if ($this->getSigma() > $this->max) {
$obQuery->where('p.price/p.quantity < ?', $this->getSigma(1));
}
if ($this->getSigma() < $this->min) {
$obQuery->where('p.price/p.quantity > ?', $this->getSigma(-1));
}
$obQuery->where('b.product_qty = ? AND b.product_measure = ? ', $this->qty, $this->measure);
return iterFirst($obQuery->execute());
}
示例12: resolveEntityNamesByIds
public function resolveEntityNamesByIds($diff = array())
{
foreach ($diff as $entity => $value) {
$diff = $this->_resolveBarcodeEntities($diff, $entity, $value);
$diff = $this->_resolveGpcEntities($diff, $entity, $value);
$diff = $this->_resolveGpcAttributes($diff, $entity, $value);
if ($entity == 'cover_code' && !empty($value)) {
$obCover = iterFirst(M('Store')->requestQuery(M('Store')->factoryObject(), M('Db')->createQuery(M('Barcode')->table('covers'))->what('CoverName name ')->where('CID = ? ', $value)));
$diff[$entity] = !isNull($obCover) ? $obCover->name : $value;
}
}
return $diff;
}
示例13: _ignoreIncrease
protected function _ignoreIncrease(RM_Points_Account $obAccount, array $params)
{
if (isNull($obUser = M('User')->loadUserById($obAccount->user_id))) {
return TRUE;
}
if (isNull($obPerson = iterFirst($obUser->getMainPerson()))) {
return TRUE;
}
if ($obPerson->sex != 1) {
return TRUE;
}
return FALSE;
}
示例14: checkDbRec
function checkDbRec($id, $table, $qw2Props, $props = array())
{
$rec = iterFirst(M('Db')->query("SELECT * FROM {$table} WHERE id=?", $id));
T()->ok($id, "#{$id} is valid");
T()->ok(!isNull($rec), "record#{$id} exists in {$table}");
$expected = array();
//
// here we do some trick: '!' in expected props means "any non-empty value"
//
foreach (array_merge($qw2Props, $props) as $p => $val) {
$expected[$p] = ($val == '!' and $rec[$p]) ? $rec[$p] : $val;
}
T()->is_hash_eq($rec, $expected, "record#{$id} validness");
}
示例15: save
public function save()
{
$barcode = $this->_object->getBarcode(TRUE);
if ($this->_isAddToModeration()) {
if (isNull($queue = iterFirst(M('Barcode')->getQueueList()->filter('purchase_id=?', $this->_object->id())))) {
$queue = M('Barcode')->createQueue(array('user_id' => me()->id(), 'purchase_id' => $this->_object->id(), 'barcode_value' => $this->_object->barcode_value, 'name_old' => isNull($barcode) ? NULL : $barcode->attribute_1, 'refreshed' => isNull($barcode) ? 0 : $barcode->to_refresh));
}
if (!$queue->moderated) {
$queue->name_new = $this->_object->corrected_name;
$queue->save();
M('Points')->registerNewBarcode($this->_object);
}
}
//me()->refreshDay($this->_object->bdate, count(M('Purchase')->getPurchaseListForDiary(me(), $this->_object->bdate)->filter('status_id=3')));
me()->refreshDayByQuery($this->_object->bdate);
}