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


PHP DataSource::load方法代码示例

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


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

示例1: getBrands

    public function getBrands()
    {
        $brands = array();
        $pdo = DataSource::load();
        $data = array();
        $statement = 'SELECT brand.*, category.name AS categoryName FROM brand
		LEFT JOIN category ON brand.category = category.id
		WHERE deleted = 0';
        if (!empty($this->categoryId)) {
            $statement .= ' AND category = :category';
            $data['category'] = $this->categoryId;
        }
        if ($this->status !== null) {
            $statement .= ' AND status = :status';
            $data['status'] = $this->status;
        }
        if (!empty($this->orderBy)) {
            $statement .= ' ORDER BY ' . $this->orderBy;
        }
        if (!empty($this->limit)) {
            $statement .= ' LIMIT ' . (int) $this->limit;
        }
        if (!empty($this->offset)) {
            $statement .= ' OFFSET ' . (int) $this->offset;
        }
        $preparedStatement = $pdo->prepare($statement);
        $preparedStatement->execute($data);
        $brandsData = $preparedStatement->fetchAll();
        foreach ($brandsData as $brandData) {
            $brand = new Brand();
            $brand->setProperties($brandData);
            $brands[] = $brand;
        }
        return $brands;
    }
开发者ID:Aqro,项目名称:findguidelines,代码行数:35,代码来源:BrandQuery.php

示例2: create

 public function create()
 {
     $pdo = DataSource::load();
     $statement = 'INSERT INTO click
 (brand, creation_time)
 VALUES (:brand, :creation_time)';
     $data = array();
     $data['brand'] = $this->brand;
     $data['creation_time'] = date('Y-m-d H:i:s');
     $preparedStatement = $pdo->prepare($statement);
     return $preparedStatement->execute($data);
 }
开发者ID:Aqro,项目名称:findguidelines,代码行数:12,代码来源:BrandClick.php

示例3: getLatest

 public static function getLatest($limit)
 {
     $limit = (int) $limit;
     $logs = array();
     $pdo = DataSource::load();
     $statement = 'SELECT log.*, brand.name AS brandName, brand.brandColor AS brandColor, brand.slug AS brandSlug FROM log
 LEFT JOIN brand ON log.brand = brand.id
 ORDER BY log.date DESC
 LIMIT :limit';
     $preparedStatement = $pdo->prepare($statement);
     $preparedStatement->bindParam('limit', $limit, PDO::PARAM_INT);
     $preparedStatement->execute();
     $logsData = $preparedStatement->fetchAll();
     foreach ($logsData as $logData) {
         $log = new self();
         $log->setProperties($logData);
         $logs[] = $log;
     }
     return $logs;
 }
开发者ID:Aqro,项目名称:findguidelines,代码行数:20,代码来源:Log.php

示例4: addLoader

 public function addLoader($datasourceType, DataSource $datasource)
 {
     foreach ($this->config as $maphperName => $sourceConfig) {
         if ($sourceConfig['type'] != $datasourceType) {
             continue;
         }
         $this->dice->addRule('$Maphper_Source_' . $maphperName, $datasource->load($sourceConfig));
         $rules = [];
         if (isset($sourceConfig['relations'])) {
             foreach ($sourceConfig['relations'] as $relationConfig) {
                 if ($relationConfig['type'] === 'ManyMany') {
                     continue;
                 }
                 $relation = [];
                 $relation['instanceOf'] = 'Maphper\\Relation\\' . ucwords($relationConfig['type']);
                 $relation['substitutions'] = ['Maphper\\Maphper' => ['instance' => '$Maphper_' . $relationConfig['to']]];
                 $relation['constructParams'] = [$relationConfig['localKey'], $relationConfig['foreignKey']];
                 $name = '$Maphper_Relation_' . $maphperName . '_' . $relationConfig['name'];
                 $rules[$relationConfig['name']] = $name;
                 $this->dice->addRule($name, $relation);
             }
         }
         $mapper = [];
         $mapper['instanceOf'] = 'Maphper\\Maphper';
         $mapper['substitutions'] = ['Maphper\\DataSource' => ['instance' => '$Maphper_Source_' . $maphperName]];
         //$mapper['shared'] = true;
         $mapper['call'] = [];
         foreach ($rules as $name => $rule) {
             $mapper['call'][] = ['addRelation', [$name, ['instance' => $rule]]];
         }
         // If `resultCLass` option is set then automatically use Dice to resolve dependencies
         if (isset($sourceConfig['resultClass'])) {
             $mapper['constructParams'] = [['resultClass' => function () use($sourceConfig) {
                 return $this->dice->create($sourceConfig['resultClass']);
             }]];
         }
         $this->dice->addRule('$Maphper_' . $maphperName, $mapper);
     }
 }
开发者ID:solleer,项目名称:Maphper-Loader,代码行数:39,代码来源:Json.php

示例5: users

 public function users()
 {
     $pdo = DataSource::load();
     $statement = 'SELECT id, firstName, lastName, login  FROM User';
     $preparedStatement = $pdo->prepare($statement);
     $preparedStatement->execute();
     $usersData = $preparedStatement->fetchAll();
     $this->set('usersData', $usersData);
     $this->render('administration/users');
 }
开发者ID:Aqro,项目名称:findguidelines,代码行数:10,代码来源:AdministrationController.php

示例6: __viewIndex

 public function __viewIndex()
 {
     // This is the 'correct' way to append a string containing an entity
     $title = $this->createElement('title');
     $title->appendChild($this->createTextNode(__('Symphony') . ' '));
     $title->appendChild($this->createEntityReference('ndash'));
     $title->appendChild($this->createTextNode(' ' . __('Data Sources')));
     $this->insertNodeIntoHead($title);
     $this->appendSubheading(__('Data Sources'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . '/new/', array('title' => __('Create a new data source'), 'class' => 'create button')));
     $datasources = new DatasourceIterator();
     $dsTableHead = array(array(__('Name'), 'col'), array(__('Source'), 'col'), array(__('Type'), 'col'), array(__('Used By'), 'col'));
     $dsTableBody = array();
     $colspan = count($dsTableHead);
     if ($datasources->length() <= 0) {
         $dsTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), array('class' => 'inactive', 'colspan' => $colspan))), array('class' => 'odd')));
     } else {
         //	Load Views so we can determine what Datasources are attached
         if (!self::$_loaded_views) {
             foreach (new ViewIterator() as $view) {
                 self::$_loaded_views[$view->guid] = array('title' => $view->title, 'handle' => $view->handle, 'data-sources' => $view->{'data-sources'});
             }
         }
         foreach ($datasources as $pathname) {
             $ds = DataSource::load($pathname);
             $view_mode = $ds->allowEditorToParse() == true ? 'edit' : 'info';
             $handle = DataSource::getHandleFromFilename($pathname);
             // Name
             $col_name = Widget::TableData(Widget::Anchor($ds->about()->name, ADMIN_URL . "/blueprints/datasources/{$view_mode}/{$handle}/", array('title' => $ds->parameters()->pathname)));
             $col_name->appendChild(Widget::Input("items[{$handle}]", NULL, 'checkbox'));
             // Source
             try {
                 $col_source = $ds->prepareSourceColumnValue();
             } catch (Exception $e) {
                 $col_source = Widget::TableData(__('None'), array('class' => 'inactive'));
             }
             // Used By
             $fragment_views = $this->createDocumentFragment();
             foreach (self::$_loaded_views as $view) {
                 if (is_array($view['data-sources']) && in_array($handle, $view['data-sources'])) {
                     if ($fragment_views->hasChildNodes()) {
                         $fragment_views->appendChild(new DOMText(', '));
                     }
                     $fragment_views->appendChild(Widget::Anchor($view['title'], ADMIN_URL . "/blueprints/views/edit/{$view['handle']}/"));
                 }
             }
             if (!$fragment_views->hasChildNodes()) {
                 $col_views = Widget::TableData(__('None'), array('class' => 'inactive'));
             } else {
                 $col_views = Widget::TableData($fragment_views);
             }
             // Type
             if (is_null($ds->getType())) {
                 $col_type = Widget::TableData(__('Unknown'), array('class' => 'inactive'));
             } else {
                 $col_type = Widget::TableData($this->types[$ds->getType()]->name);
             }
             $dsTableBody[] = Widget::TableRow(array($col_name, $col_source, $col_type, $col_views));
         }
     }
     $table = Widget::Table(Widget::TableHead($dsTableHead), NULL, Widget::TableBody($dsTableBody), array('id' => 'datasources-list'));
     $this->Form->appendChild($table);
     $tableActions = $this->createElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete')));
     $tableActions->appendChild(Widget::Select('with-selected', $options));
     $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $this->Form->appendChild($tableActions);
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:68,代码来源:content.blueprintsdatasources.php

示例7: updateClicksCount

    public function updateClicksCount()
    {
        if ($this->hasId()) {
            $pdo = DataSource::load();
            $statement = 'UPDATE brand
			SET clicksCount = (SELECT COUNT(*) FROM click WHERE click.brand = brand.id)
			WHERE id = :brandId;';
            $data = array();
            $data['brandId'] = (int) $this->getId();
            $preparedStatement = $pdo->prepare($statement);
            return $preparedStatement->execute($data);
        }
        return false;
    }
开发者ID:Aqro,项目名称:findguidelines,代码行数:14,代码来源:Brand.php

示例8: delete

 public static function delete(Section $section)
 {
     /*
     	TODO:
     	Upon deletion it should update all data-sources/events attached to it.
     	Either by deleting them, or making section $unknown.
     
     	I think deletion is best because if the section is renamed, the rename()
     	function will take care of moving the dependancies, so there should be
     	no data-sources/events to delete anyway.
     
     	However, if you delete page accidentally (hm, even though you clicked
     	confirm), do you really want your data-sources/events to just be deleted?
     
     	Verdict?
     */
     // 	Remove fields:
     foreach ($section->fields as $field) {
         $field->remove();
     }
     // 	Remove sync data:
     Symphony::Database()->delete('tbl_sections_sync', array($section->guid), '`section` = "%s"');
     //	Remove entry metadata
     Symphony::Database()->delete('tbl_entries', array($section->handle), '`section` = "%s"');
     if (General::deleteFile(SECTIONS . '/' . $section->handle . '.xml')) {
         //	Cleanup Datasources
         foreach (new DataSourceIterator() as $datasource) {
             $ds = DataSource::load($datasource);
             if ($ds->parameters()->section == $section->handle) {
                 DataSource::delete($ds);
             }
         }
         //	Cleanup Events
         foreach (new EventIterator() as $event) {
             $ev = Event::load($event);
             if ($ev->parameters()->source == $section->handle) {
                 Event::delete($ev);
             }
         }
     }
 }
开发者ID:pointybeard,项目名称:symphony-3,代码行数:41,代码来源:class.section.php

示例9: isset

?>
" required autofocus>
          </div>
          <div class="form-group">
            <label for="aemenudesc">Description</label>
            <textarea class="form-control" name="description" rows="5" id="aemenudesc" maxlength="1000"><?php 
echo isset($menudesc) ? $menudesc : '';
?>
</textarea>
          </div>
          <div class="form-group">
            <label for="aemenusource">Data Source</label>
            <select class="form-control" id="aemenusource" name="menusource">
              <option></option>
<?php 
$datasources = DataSource::load();
foreach ($datasources as $datasource => $datasourcename) {
    echo '          <option value="' . $datasource . '" ' . ($datasource == $menusource ? 'selected' : '') . '>' . $datasourcename . '</option>';
}
?>
            </select>
          </div>
          <div class="pull-right">
<?php 
if ($pageaction == 'add') {
    $buttonvalue = 'addmenu';
    $buttonlabel = 'Add Menu';
} else {
    $buttonvalue = 'editmenu';
    $buttonlabel = 'Save Changes';
}
开发者ID:auimendoza,项目名称:appfoodsyadmin,代码行数:31,代码来源:aemenu.php

示例10: delete

 public function delete()
 {
     $pdo = DataSource::load();
     if ($this->hasId()) {
         $statement = 'DELETE FROM user WHERE id = :id';
         $preparedStatement = $pdo->prepare($statement);
         $data['id'] = $this->id;
         if ($preparedStatement->execute($data)) {
             $this->id = 0;
             return true;
         }
     }
     return false;
 }
开发者ID:Aqro,项目名称:findguidelines,代码行数:14,代码来源:User.php

示例11: getAll

 public static function getAll()
 {
     $categories = array();
     $pdo = DataSource::load();
     $statement = 'SELECT * FROM category';
     $preparedStatement = $pdo->prepare($statement);
     $preparedStatement->execute();
     $categoriesData = $preparedStatement->fetchAll();
     foreach ($categoriesData as $categoryData) {
         $category = new self();
         $category->setProperties($categoryData);
         $categories[] = $category;
     }
     return $categories;
 }
开发者ID:Aqro,项目名称:findguidelines,代码行数:15,代码来源:BrandCategory.php

示例12: __form

 public function __form()
 {
     $layout = new Layout();
     $left = $layout->createColumn(Layout::LARGE);
     $center = $layout->createColumn(Layout::LARGE);
     $right = $layout->createColumn(Layout::LARGE);
     $existing = null;
     $fields = array();
     // Verify view exists:
     if ($this->_context[0] == 'edit') {
         if (!isset($this->_context[1]) || strlen(trim($this->_context[1])) == 0) {
             redirect(ADMIN_URL . '/blueprints/views/');
         }
         $context = $this->_context;
         array_shift($context);
         $view_pathname = implode('/', $context);
         $existing = self::__loadExistingView($view_pathname);
     }
     // Status message:
     $callback = Administration::instance()->getPageCallback();
     if (isset($callback['flag']) && !is_null($callback['flag'])) {
         switch ($callback['flag']) {
             case 'saved':
                 $this->alerts()->append(__('View updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/views/new/', ADMIN_URL . '/blueprints/views/')), AlertStack::SUCCESS);
                 break;
             case 'created':
                 $this->alerts()->append(__('View created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/views/new/', ADMIN_URL . '/blueprints/views/')), AlertStack::SUCCESS);
                 break;
         }
     }
     // Find values:
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
     } elseif ($this->_context[0] == 'edit') {
         $fields = (array) $existing->about();
         // Flatten the types array:
         $fields['types'] = (isset($fields['types']) and is_array($fields['types'])) ? implode(', ', $fields['types']) : null;
         // Flatten the url-parameters array:
         $fields['url-parameters'] = (isset($fields['url-parameters']) and is_array($fields['url-parameters'])) ? implode('/', $fields['url-parameters']) : null;
         $fields['parent'] = $existing->parent() instanceof View ? $existing->parent()->path : NULL;
         $fields['handle'] = $existing->handle;
     }
     $title = null;
     if (isset($fields['title'])) {
         $title = $fields['title'];
     }
     if (strlen(trim($title)) == 0) {
         $title = $existing instanceof View ? $existing->title : 'New View';
     }
     $this->setTitle(__($title ? '%1$s &ndash; %2$s &ndash; %3$s' : '%1$s &ndash; %2$s', array(__('Symphony'), __('Views'), $title)));
     if ($existing instanceof View) {
         $template_name = $fields['handle'];
         $this->appendSubheading(__($title ? $title : __('New View')));
         $viewoptions = array(__('Configuration') => Administration::instance()->getCurrentPageURL(), __('Template') => sprintf('%s/blueprints/views/template/%s/', ADMIN_URL, $view_pathname));
         $this->appendViewOptions($viewoptions);
     } else {
         $this->appendSubheading($title ? $title : __('Untitled'));
     }
     // Fieldset -----------------------------------------------------------
     $fieldset = Widget::Fieldset(__('Essentials'));
     // Title --------------------------------------------------------------
     $label = Widget::Label(__('Title'));
     $label->appendChild(Widget::Input('fields[title]', isset($fields['title']) ? $fields['title'] : null));
     if (isset($this->errors->title)) {
         $label = Widget::wrapFormElementWithError($label, $this->errors->title);
     }
     $fieldset->appendChild($label);
     // Type ---------------------------------------------------------------
     $container = $this->createElement('div');
     $label = Widget::Label(__('View Type'));
     $label->appendChild(Widget::Input('fields[types]', isset($fields['types']) ? $fields['types'] : null));
     if (isset($this->errors->types)) {
         $label = Widget::wrapFormElementWithError($label, $this->errors->types);
     }
     $tags = $this->createElement('ul');
     $tags->setAttribute('class', 'tags');
     foreach (self::__fetchAvailableViewTypes() as $t) {
         $tags->appendChild($this->createElement('li', $t));
     }
     $container->appendChild($label);
     $container->appendChild($tags);
     $fieldset->appendChild($container);
     $left->appendChild($fieldset);
     // Fieldset -----------------------------------------------------------
     $fieldset = Widget::Fieldset(__('URL Settings'));
     // Parent -------------------------------------------------------------
     $label = Widget::Label(__('Parent'));
     $options = array(array(NULL, false, '/'));
     foreach (new ViewIterator() as $v) {
         // Make sure the current view cannot be set as either a child of itself, or a child of
         // another view that is already at child of the current view.
         if (isset($existing) && $existing instanceof View && ($v->isChildOf($existing) || $v->guid == $existing->guid)) {
             continue;
         }
         $options[] = array($v->path, isset($fields['parent']) and $fields['parent'] == $v->path, "/{$v->path}");
     }
     $label->appendChild(Widget::Select('fields[parent]', $options));
     $fieldset->appendChild($label);
     // Handle -------------------------------------------------------------
     $label = Widget::Label(__('Handle'));
//.........这里部分代码省略.........
开发者ID:brendo,项目名称:symphony-3,代码行数:101,代码来源:content.blueprintsviews.php


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