当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Collection::count方法代码示例

本文整理汇总了PHP中Doctrine_Collection::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Collection::count方法的具体用法?PHP Doctrine_Collection::count怎么用?PHP Doctrine_Collection::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Collection的用法示例。


在下文中一共展示了Doctrine_Collection::count方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

    public function __construct($record, $opts)
    {
        $componentName = $record->getTable()->getComponentName();

        $q = $record->getTable()->createQuery();

        $params = array($record->get('lft'), $record->get('rgt'));
        if (isset($opts['include_record']) && $opts['include_record']) {
            $query = $q->where("$componentName.lft >= ? AND $componentName.rgt <= ?", $params)->orderBy("$componentName.lft asc");
        } else {
            $query = $q->where("$componentName.lft > ? AND $componentName.rgt < ?", $params)->orderBy("$componentName.lft asc");
        }

        $query = $record->getTable()->getTree()->returnQueryWithRootId($query, $record->getNode()->getRootValue());

        $this->maxLevel   = isset($opts['depth']) ? ($opts['depth'] + $record->getNode()->getLevel()) : 0;
        $this->options    = $opts;
        $this->collection = isset($opts['collection']) ? $opts['collection'] : $query->execute();
        $this->keys       = $this->collection->getKeys();
        $this->count      = $this->collection->count();
        $this->index      = -1;
        $this->level      = $record->getNode()->getLevel();
        $this->prevLeft   = $record->getNode()->getLeftValue();

        // clear the table identity cache
        $record->getTable()->clear();
    }
开发者ID:nationalfield,项目名称:symfony,代码行数:27,代码来源:PreOrderIterator.php

示例2: collectionToTree

 /**
  * @param Doctrine_Collection $collection
  * @param int $position position into collection
  * @param int $level
  * @return array
  */
 public static function collectionToTree(Doctrine_Collection $collection, &$position = 0, $level = 0)
 {
     $result = array();
     for ($i = $position; $i < $collection->count(); $i++) {
         if ($level < $collection[$i]->level) {
             $perv_index = $i - 1;
             $result[$collection[$perv_index]->id]['children'] = self::collectionToTree($collection, $i, $collection[$i]->level);
         } else {
             if ($level > $collection[$i]->level) {
                 // Shift loop global index
                 $position = $i - 1;
                 return $result;
             } else {
                 $result[$collection[$i]->id]['data'] = $collection[$i];
             }
         }
     }
     // Shift loop global index
     $position = $i - 1;
     return $result;
 }
开发者ID:sensorsix,项目名称:app,代码行数:27,代码来源:Utility.class.php

示例3: __construct

 /**
  * constructor
  * @var Doctrine_Collection $collection
  */
 public function __construct($collection)
 {
     $this->collection = $collection;
     $this->keys = $this->collection->getKeys();
     $this->count = $this->collection->count();
 }
开发者ID:googlecode-mirror,项目名称:orso,代码行数:10,代码来源:Iterator.php

示例4: testCount

 public function testCount()
 {
     $coll = new Doctrine_Collection($this->connection->getTable('User'));
     $this->assertEqual($coll->count(), 0);
     $coll[0];
     $this->assertEqual($coll->count(), 1);
 }
开发者ID:swk,项目名称:bluebox,代码行数:7,代码来源:CollectionTestCase.php

示例5: count

 /**
  * Return how many items are in the collection
  *
  * @return void
  */
 public function count()
 {
     return $this->_dbData->count();
 }
开发者ID:EricHogue,项目名称:Koryukan,代码行数:9,代码来源:Collection.php

示例6: getNextRecord

 /**
  * Tries to return the next record in table
  */
 public function getNextRecord(Doctrine_Collection $nearRecords)
 {
     foreach ($nearRecords as $key => $record) {
         if ($this->getOid() === $record->getOid()) {
             $myOffset = $key;
             break;
         }
     }
     if (!isset($myOffset) || $myOffset === $nearRecords->count() - 1) {
         return null;
     }
     return $nearRecords[$myOffset + 1];
 }
开发者ID:jdart,项目名称:diem,代码行数:16,代码来源:dmDoctrineRecord.php

示例7: reactivateAllAccounts

 function reactivateAllAccounts()
 {
     $user_collection = new Doctrine_Collection(Doctrine_Core::getTable("UserAccount"));
     $users = $this->getUsers();
     //debugMessage($users->toArray());
     if ($users->count() > 0) {
         foreach ($users as $user) {
             if ($user->isUserInActive() && $user->getActivationKey() == md5($this->getCompanyID())) {
                 $user->setStatus(1);
                 $user->setActivationKey('');
                 $user_collection->add($user);
             }
         }
         // debugMessage($user_collection->toArray());
     }
     if ($user_collection->count() > 0) {
         try {
             $user_collection->save();
         } catch (Exception $e) {
             debugMessage("An error occured in updating status. " . $e->getMessage());
         }
     }
     return true;
 }
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:24,代码来源:Company.php

示例8: processglobalconfigAction

 function processglobalconfigAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     $successurl = decode($formvalues[URL_SUCCESS]);
     // debugMessage($formvalues);
     $postarray = array();
     for ($i = 1; $i <= $formvalues['t']; $i++) {
         $postarray[$i]['id'] = $formvalues['id_' . $i];
         $postarray[$i]['displayname'] = $formvalues['displayname_' . $i];
         $postarray[$i]['optionvalue'] = $formvalues['optionvalue_' . $i];
     }
     $config_collection = new Doctrine_Collection(Doctrine_Core::getTable("AppConfig"));
     foreach ($postarray as $line) {
         $appconfig = new AppConfig();
         $appconfig->populate($line['id']);
         $appconfig->processPost($line);
         /*debugMessage('error is '.$appconfig->getErrorStackAsString());
         		debugMessage($appconfig->toArray());*/
         if ($appconfig->isValid()) {
             $config_collection->add($appconfig);
         }
     }
     // check for atleast one option and save
     if ($config_collection->count() > 0) {
         try {
             // debugMessage($config_collection->toArray());
             $config_collection->save();
             $session->setVar(SUCCESS_MESSAGE, $formvalues[SUCCESS_MESSAGE]);
             # clear cache after updating options
             $temppath = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR;
             // debugMessage($temppath);
             $files = glob($temppath . 'zend_cache---config*');
             foreach ($files as $file) {
                 debugMessage($file);
                 if (is_file($file)) {
                     unlink($file);
                 }
             }
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, "An error occured in updating the parameters. " . $e->getMessage());
         }
     }
     // debugMessage($successurl);
     $this->_helper->redirector->gotoUrl($successurl);
     // exit();
 }
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:49,代码来源:ConfigController.php

示例9: completeAction

 function completeAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit;
     $config = Zend_Registry::get("config");
     $payroll = new Payroll();
     $payroll->populate($this->_getParam('id'));
     $payroll->setStatus($this->_getParam('status'));
     // debugMessage($payroll->getStartDate()." - ".$payroll->getEndDate());
     $ledger_collection = new Doctrine_Collection(Doctrine_Core::getTable("Ledger"));
     $timesheet_collection = new Doctrine_Collection(Doctrine_Core::getTable("Timesheet"));
     $leave_collection = new Doctrine_Collection(Doctrine_Core::getTable("Ledger"));
     $employees = $payroll->getdetails();
     // debugMessage($employees->toArray());
     foreach ($employees as $employee) {
         $results_credits_array = array();
         // check of benefit additions
         if (decode($employee->getbenefitdetails()) != "[]" && $employee->getbenefitdetails() != "W10=") {
             $results_credits_array = objectToArray(json_decode(decode($employee->getbenefitdetails())));
             // debugMessage($results_credits_array);
             foreach ($results_credits_array as $line) {
                 if (!isArrayKeyAnEmptyString('ids', $line)) {
                     $ids_array = explode(',', $line['ids']);
                     if (count($ids_array) > 0) {
                         foreach ($ids_array as $id) {
                             $ledger = new Ledger();
                             $ledger->populate($id);
                             $ledger->setPayrollID($employee->getPayrollID());
                             $ledger_collection->add($ledger);
                             // debugMessage($ledger->toArray());
                         }
                     }
                 }
             }
         }
         // check for deductions
         if (decode($employee->getdeductiondetails()) != "[]" && $employee->getdeductiondetails() != "W10=") {
             $results_debits_array = objectToArray(json_decode(decode($employee->getdeductiondetails())));
             // debugMessage($results_credits_array);
             foreach ($results_debits_array as $line) {
                 if (!isArrayKeyAnEmptyString('ids', $line)) {
                     $ids_array = explode(',', $line['ids']);
                     if (count($ids_array) > 0) {
                         foreach ($ids_array as $id) {
                             $ledger = new Ledger();
                             $ledger->populate($id);
                             $ledger->setPayrollID($employee->getPayrollID());
                             $ledger_collection->add($ledger);
                             // debugMessage($ledger->toArray());
                         }
                     }
                 }
             }
         }
         // fetch timesheets for each employeee
         $timesheets = $employee->getUser()->getTimesheetDetails($payroll->getStartDate(), $payroll->getEndDate());
         if ($timesheets->count() > 0) {
             // debugMessage($timesheets->toArray());
             foreach ($timesheets as $timesheet) {
                 $timesheet->setPayrollID($employee->getPayrollID());
                 $timesheet_collection->add($timesheet);
             }
         }
         // generate leave accruals for period
         if ($employee->getLeaveHrs() > '0.00' && $employee->getUser()->getIsTimesheetuser() == 1) {
             // debugMessage('>'.$employee->getLeaveHrs());
             $leave = new Ledger();
             $leave_array = array("payrollid" => $payroll->getID(), "userid" => $employee->getUserID(), "ledgertype" => 2, "trxntype" => 1, "leaveid" => 1, "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "leavelength" => $employee->getLeaveHrs() * getHoursInDay(), "lengthtype" => 1, "status" => 1, "remarks" => "Auto Accrual from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'), "payrolltrigger" => 1);
             $leave->processPost($leave_array);
             /* debugMessage($leave->toArray());
             			debugMessage('errors are '.$leave->getErrorStackAsString()); */
             if (!$leave->hasError()) {
                 $leave_collection->add($leave);
             }
         }
         if ($employee->getSickHrs() > '0.00' && $employee->getUser()->getIsTimesheetuser() == 1) {
             // debugMessage('>'.$employee->getLeaveHrs());
             $leave = new Ledger();
             $leave_array = array("payrollid" => $payroll->getID(), "userid" => $employee->getUserID(), "ledgertype" => 2, "trxntype" => 1, "leaveid" => 2, "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "leavelength" => $employee->getSickHrs() * getHoursInDay(), "lengthtype" => 1, "status" => 1, "remarks" => "Auto Accrued from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'), "payrolltrigger" => 1);
             $leave->processPost($leave_array);
             /*debugMessage($leave->toArray());
             		debugMessage('errors are '.$leave->getErrorStackAsString()); */
             if (!$leave->hasError()) {
                 $leave_collection->add($leave);
             }
         }
         // generate recurring monthly benefits
         $newledgertrxns = array();
         if (decode($employee->getrecurringtrxns()) != "[]" && $employee->getrecurringtrxns() != "W10=") {
             $newledgertrxns = objectToArray(json_decode(decode($employee->getrecurringtrxns())));
             // debugMessage($newledgertrxns);
             foreach ($newledgertrxns as $line) {
                 // debugMessage($line);
                 foreach ($line as $key => $value) {
                     $ledger = new Ledger();
                     $ledger_array = array("payrollid" => $payroll->getID(), "payrolltrigger" => 1, "userid" => $employee->getUserID(), "ledgertype" => 1, "trxntype" => $value['trxntype'], "benefitid" => $value['benefitid'], "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "amount" => $value['amount'], "status" => 1, "remarks" => "Auto Accrued from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'), "istaxable" => isArrayKeyAnEmptyString('istaxable', $value) ? 0 : $value['istaxable']);
                     $ledger->processPost($ledger_array);
//.........这里部分代码省略.........
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:101,代码来源:PayrollController.php


注:本文中的Doctrine_Collection::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。