本文整理汇总了PHP中object::count方法的典型用法代码示例。如果您正苦于以下问题:PHP object::count方法的具体用法?PHP object::count怎么用?PHP object::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderIndex
protected function renderIndex()
{
$data['schema'] = $this->model->schema;
$data['primary'] = $this->model->primary;
//$this->
$where = [];
$grid['filter'] = isset($this->grid['filter']) ? $this->grid['filter'] : [];
foreach ($grid['filter'] as $key => $value) {
if ($this->input->get($key)) {
$where[$key] = $this->input->get($key);
}
}
$grid['page'] = isset($this->grid['page']) ? $this->grid['page'] : (intval($this->input->get('page')) ? intval($this->input->get('page')) : 1);
$grid['pageSize'] = isset($this->grid['pageSize']) ? $this->grid['pageSize'] : 12;
$grid['total'] = isset($this->grid['total']) ? $this->grid['total'] : $this->model->count($where);
$grid['fields'] = isset($this->grid['fields']) ? $this->grid['fields'] : array_keys($this->model->schema);
$grid['fieldshow'] = isset($this->grid['fieldshow']) ? $this->grid['fieldshow'] : null;
$grid['datasource'] = isset($this->grid['page']) ? $this->grid['datasource'] : $this->model->query($where, $grid['fields'], [$this->model->primary => 'desc'], [$grid['pageSize'] * ($grid['page'] - 1), $grid['pageSize']]);
$grid['pager'] = isset($this->grid['pager']) ? $this->grid['pager'] : $this->helper->backstage->paging($grid['pageSize'], $grid['total'], $grid['page'], $this->helper->backstage->uri(['page' => '']));
$grid['tools'] = isset($this->grid['tools']) ? $this->grid['tools'] : ['add' => $this->helper->form->button(['properties' => ['id' => 'add', 'onclick' => 'edit()'], 'label' => '增加'])];
$grid['operations'] = isset($this->grid['operations']) ? $this->grid['operations'] : [['name' => '操作', 'action' => function ($record) {
return '<a href="javascript:del(' . $record->id . ')">删除</a> | <a href="javascript:update(' . $record->id . ')">修改</a>';
}]];
$data['grid'] = $grid;
$this->output->view('common/index', $data);
}
示例2: removeParent
/**
* Unset a parent.
*
* @param pbject $parent The parent instance to unset.
* @return self
*/
public function removeParent($parent)
{
$this->_parents->remove($parent);
if ($this->_parents->count() === 0) {
$this->collector()->remove($this->uuid());
}
return $this;
}
示例3: hasTickets
/**
* hasTickets - check if there are Tickets related to a project
*
* @access public
* @param $id
* @return boolean
*/
public function hasTickets($id)
{
$query = "SELECT id FROM zp_tickets WHERE projectId = '" . $id . "' LIMIT 1";
$this->db->dbQuery($query);
if ($this->db->count() == 0) {
return false;
} else {
return true;
}
}
示例4: hasTickets
/**
* hasTickets - check if a project has Tickets
*
* @access public
* @param $id
* @return boolean
*/
public function hasTickets($id)
{
$query = "SELECT zp_projects.id FROM zp_projects JOIN zp_tickets ON zp_projects.id = zp_tickets.projectId WHERE zp_projects.clientId = '" . $id . "'";
$this->db->dbQuery($query);
if ($this->db->count() == 0) {
return false;
} else {
return true;
}
}
示例5: parseAlbums
/**
* parseAlbums function.
*
* @access private
* @return void
*/
private function parseAlbums()
{
if (!is_object($this->objAlbums) || $this->objAlbums->count() < 1) {
$this->setEmptyTemplate($GLOBALS['TL_LANG']['MSC']['albumsNotFound']);
return;
}
// Import
$this->import('Session');
// Define vars
global $objPage;
$arrItems = array();
$objAlbums = $this->objAlbums;
$total = $objAlbums->count();
$i = 0;
// Set page session vars to generate backlink in detail page
$this->Session->set('pa2PageNumber_' . $this->Template->id, \Input::get('page') ? \Input::get('page') : 1);
$this->Session->set('pa2PageId_' . $this->Template->id, $objPage->id);
if ($objAlbums !== null) {
while ($objAlbums->next()) {
// Generate subtemplate object
$objSubtemplate = new \FrontendTemplate($this->Template->strSubtemplate);
$objSubtemplate->setData($this->Template->getData());
// Set template variables
$objSubtemplate->title = strip_tags($objAlbums->title);
$objSubtemplate->alt = strip_tags($objAlbums->title);
$objSubtemplate->showTitle = $objSubtemplate->title != '' ? $objSubtemplate->showTitle : false;
$objSubtemplate->event = $objAlbums->event;
$objSubtemplate->place = $objAlbums->place;
$objSubtemplate->photographer = $objAlbums->photographer;
$objSubtemplate->description = $objAlbums->description;
$objSubtemplate->numberOfAllImages = count($objAlbums->arrSortedImageUuids);
// Call template methods
$objSubtemplate = $this->addDateToTemplate($objSubtemplate, $objAlbums->startdate, $objAlbums->enddate);
$objSubtemplate = $this->addSpecificClassesToTemplate($objSubtemplate, $i);
$objSubtemplate = $this->addLinkToTemplate($objSubtemplate, $objAlbums->current());
$objSubtemplate = $this->addMetaFieldsToTemplate($objSubtemplate);
// Add preview image to template
$objPa2PreviewImage = new \Pa2PreviewImage($objAlbums->current(), $objSubtemplate->pa2PreviewImage);
$objPa2Image = new \Pa2Image($objPa2PreviewImage->getPreviewImageUuid());
$objPa2Image->addPa2ImageToTemplate($objSubtemplate);
// Add album class to the class string
$objSubtemplate->class .= $objSubtemplate->class == '' ? $objAlbums->cssClass : ' ' . $objAlbums->cssClass;
// If album lightbox is activated the images will be added to the album template
$objSubtemplate = $this->albumLightbox($objSubtemplate, $objAlbums->current());
// Parse subtemplate
$arrItems[] = $objSubtemplate->parse();
$i++;
}
}
$this->Template->items = $arrItems;
}
示例6: get_venues
public function get_venues($per_page = 10, $count = FALSE)
{
$_orderby = !empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
switch ($_orderby) {
case 'id':
$orderby = 'VNU_ID';
break;
case 'capacity':
$orderby = 'VNU_capacity';
break;
case 'city':
$orderby = 'VNU_city';
break;
default:
$orderby = 'VNU_name';
}
$sort = isset($this->_req_data['order']) && !empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
$current_page = isset($this->_req_data['paged']) && !empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
$per_page = isset($per_page) && !empty($per_page) ? $per_page : 10;
$per_page = isset($this->_req_data['perpage']) && !empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
$offset = ($current_page - 1) * $per_page;
$limit = array($offset, $per_page);
$category = isset($this->_req_data['category']) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL;
$where = array();
//only set initial status if it is in the incoming request. Otherwise the "all" view display's all statuses.
if (isset($this->_req_data['status']) && $this->_req_data['status'] != 'all') {
$where['status'] = $this->_req_data['status'];
}
if (isset($this->_req_data['venue_status'])) {
$where['status'] = $this->_req_data['venue_status'];
}
if ($category) {
$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
$where['Term_Taxonomy.term_id'] = $category;
}
if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
$where['VNU_wp_user'] = get_current_user_id();
} else {
if (!EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
$where['OR'] = array('status*restrict_private' => array('!=', 'private'), 'AND' => array('status*inclusive' => array('=', 'private'), 'VNU_wp_user' => get_current_user_id()));
}
}
if (isset($this->_req_data['s'])) {
$sstr = '%' . $this->_req_data['s'] . '%';
$where['OR'] = array('VNU_name' => array('LIKE', $sstr), 'VNU_desc' => array('LIKE', $sstr), 'VNU_short_desc' => array('LIKE', $sstr), 'VNU_address' => array('LIKE', $sstr), 'VNU_address2' => array('LIKE', $sstr), 'VNU_city' => array('LIKE', $sstr), 'VNU_zip' => array('LIKE', $sstr), 'VNU_phone' => array('LIKE', $sstr), 'VNU_url' => array('LIKE', $sstr), 'VNU_virtual_phone' => array('LIKE', $sstr), 'VNU_virtual_url' => array('LIKE', $sstr), 'VNU_google_map_link' => array('LIKE', $sstr), 'Event.EVT_name' => array('LIKE', $sstr), 'Event.EVT_desc' => array('LIKE', $sstr), 'Event.EVT_phone' => array('LIKE', $sstr), 'Event.EVT_external_URL' => array('LIKE', $sstr));
}
$venues = $count ? $this->_venue_model->count(array($where), 'VNU_ID') : $this->_venue_model->get_all(array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort));
return $venues;
}
示例7: encode
/**
* Encode the result set into a collection of models
* @param object $resultSet The result set to hydrate with
* @param object $modelToHydrate The model to hydrate
* @return boolean|\Application\Model\BlogPost
*/
public function encode($resultSet, $modelToHydrate)
{
$collection = array();
if ($resultSet->count() == 0) {
return false;
}
foreach ($resultSet as $row) {
foreach ($this->fields as $key => $value) {
if (isset($row[$value])) {
$row[$key] = $row[$value];
}
}
array_push($collection, new $modelToHydrate($row));
}
return $collection;
}
示例8: version
/**
* Load Page Version
*
* @param mixed $vid Version Id
* @return object \Components\Groups\Models\Page\Version
*/
public function version($vid = null)
{
// var to hold version
$version = new Page\Version();
// make sure we have versions to return
if ($this->_versions->count() > 0) {
// return version object
if ($vid == null || $vid == 0 || $vid == 'current') {
$version = $this->_versions->first();
} else {
if (is_numeric($vid)) {
$version = $this->_versions->fetch('version', $vid);
}
}
}
//return version
return $version;
}
示例9: get_venues
public function get_venues($per_page = 10, $count = FALSE)
{
$_orderby = !empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
switch ($_orderby) {
case 'id':
$orderby = 'VNU_ID';
break;
case 'capacity':
$orderby = 'VNU_capacity';
break;
case 'city':
$orderby = 'VNU_city';
break;
default:
$orderby = 'VNU_name';
}
$sort = isset($this->_req_data['order']) && !empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
$current_page = isset($this->_req_data['paged']) && !empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
$per_page = isset($per_page) && !empty($per_page) ? $per_page : 10;
$per_page = isset($this->_req_data['perpage']) && !empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
$offset = ($current_page - 1) * $per_page;
$limit = array($offset, $per_page);
$category = isset($this->_req_data['category']) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL;
$where = array('status' => isset($this->_req_data['status']) && $this->_req_data['status'] != 'all' ? $this->_req_data['status'] : array('IN', array('publish', 'draft')));
if ($category) {
$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
$where['Term_Taxonomy.term_id'] = $category;
}
//cap checks
if (EE_Registry::instance()->CAP->current_user_can('ee_edit_private_venues', 'get_venue')) {
if (!empty($where['status'][0]) && $where['status'][0] == 'IN') {
$where['status'][1][] = 'private';
}
}
if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
$where['VNU_wp_user'] = get_current_user_id();
}
if (isset($this->_req_data['s'])) {
$sstr = '%' . $this->_req_data['s'] . '%';
$where['OR'] = array('VNU_name' => array('LIKE', $sstr), 'VNU_desc' => array('LIKE', $sstr), 'VNU_short_desc' => array('LIKE', $sstr), 'VNU_address' => array('LIKE', $sstr), 'VNU_address2' => array('LIKE', $sstr), 'VNU_city' => array('LIKE', $sstr), 'VNU_zip' => array('LIKE', $sstr), 'VNU_phone' => array('LIKE', $sstr), 'VNU_url' => array('LIKE', $sstr), 'VNU_virtual_phone' => array('LIKE', $sstr), 'VNU_virtual_url' => array('LIKE', $sstr), 'VNU_google_map_link' => array('LIKE', $sstr), 'Event.EVT_name' => array('LIKE', $sstr), 'Event.EVT_desc' => array('LIKE', $sstr), 'Event.EVT_phone' => array('LIKE', $sstr), 'Event.EVT_external_URL' => array('LIKE', $sstr));
}
$venues = $count ? $this->_venue_model->count(array($where), 'VNU_ID') : $this->_venue_model->get_all(array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort));
return $venues;
}
示例10: render_inputs
/**
* Generate HTML string of form input controls
*
* @param string $details
* @return void
* @author Drew McLellan
*/
public function render_inputs($details = array())
{
$s = '';
$id = $this->Tag->id();
$attrs = array();
if ($this->Tag->placeholder()) {
$attrs[] = 'placeholder="' . PerchUtil::html($this->Tag->placeholder(), true) . '"';
}
if ($this->Tag->count()) {
if ($this->Tag->count() == 'chars') {
$attrs[] = 'data-count="chars"';
}
if ($this->Tag->count() == 'words') {
$attrs[] = 'data-count="words"';
}
$attrs[] = 'data-count-container="' . $this->Tag->input_id() . '__count"';
}
$attrs = implode(' ', $attrs);
$s = $this->Form->text($this->Tag->input_id(), $this->Form->get($details, $id, $this->Tag->default(), $this->Tag->post_prefix()), $this->Tag->size(), $this->Tag->maxlength(), 'text', $attrs . $this->Tag->get_data_attribute_string());
if ($this->Tag->count()) {
$s .= '<div class="counter text-counter" id="' . $this->Tag->input_id() . '__count"></div>';
}
return $s;
}
示例11: count
/**
* Countable implementation
*
* @return int number of documents
*/
public function count()
{
return $this->result->count();
}
示例12: objectToString
/**
* Render an object to a string
*
* @param Wire|object $value
* @return string
*
*/
protected function objectToString($value)
{
if ($value instanceof WireArray && !$value->count()) {
return '';
}
if ($value instanceof Page) {
return $value->get('title|name');
}
if ($value instanceof Pagefiles || $value instanceof Pagefile) {
$out = $this->renderInputfieldValue($value);
} else {
$className = get_class($value);
$out = (string) $value;
if ($out === $className) {
// just the class name probably isn't useful here, see if we can do do something else with it
$this->renderIsUseless = true;
}
}
return $out;
}
示例13: _getProductPos
/**
* Searches for current article in article list and sets previous/next product ids
*
* @param oxarticle $oArticle current Article
* @param object $oIdList articles list containing only fake article objects !!!
* @param oxubase $oLocatorTarget oxubase object
*
* @return integer
*/
protected function _getProductPos($oArticle, $oIdList, $oLocatorTarget)
{
$iCnt = 1;
$iPos = 0;
// variant handling
$sOxid = $oArticle->oxarticles__oxparentid->value ? $oArticle->oxarticles__oxparentid->value : $oArticle->getId();
if ($oIdList->count() && isset($oIdList[$sOxid])) {
$aIds = $oIdList->arrayKeys();
$iPos = oxRegistry::getUtils()->arrayStringSearch($sOxid, $aIds);
if (array_key_exists($iPos - 1, $aIds)) {
$oBackProduct = oxNew('oxArticle');
$oBackProduct->modifyCacheKey('_locator');
$oBackProduct->setNoVariantLoading(true);
if ($oBackProduct->load($aIds[$iPos - 1])) {
$oBackProduct->setLinkType($oLocatorTarget->getLinkType());
$this->_oBackProduct = $oBackProduct;
}
}
if (array_key_exists($iPos + 1, $aIds)) {
$oNextProduct = oxNew('oxArticle');
$oNextProduct->modifyCacheKey('_locator');
$oNextProduct->setNoVariantLoading(true);
if ($oNextProduct->load($aIds[$iPos + 1])) {
$oNextProduct->setLinkType($oLocatorTarget->getLinkType());
$this->_oNextProduct = $oNextProduct;
}
}
return $iPos + 1;
}
return 0;
}
示例14: _getXMLParams
/**
* parse SimpleXMLElement instance property parameters and return iCalcreator property parameter array
*
* @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se>
* @since 2.11.2 - 2012-01-15
* @param object $parameters SimpleXMLElement
* @return array iCalcreator property parameter array
*/
function _getXMLParams(&$parameters)
{
if (1 > $parameters->count()) {
return array();
}
$params = array();
foreach ($parameters->children() as $parameter) {
// single parameter key
$key = strtoupper($parameter->getName());
$value = array();
foreach ($parameter->children() as $paramValue) {
// skip parameter value type
$value[] = reset($paramValue);
}
if (2 > count($value)) {
$params[$key] = html_entity_decode(reset($value));
} else {
$params[$key] = $value;
}
}
return $params;
}
示例15: toTree
/**
* Turn a list of rows into a tree
*
* @param object $rows
* @return array
*/
public function toTree($rows)
{
$results = array();
if ($rows->count() > 0) {
$children = array(0 => array());
foreach ($rows as $row) {
$pt = $row->get('parent');
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $row);
$children[$pt] = $list;
}
$results = $this->treeRecurse($children[0], $children);
}
return $results;
}