當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mapper類代碼示例

本文整理匯總了PHP中Mapper的典型用法代碼示例。如果您正苦於以下問題:PHP Mapper類的具體用法?PHP Mapper怎麽用?PHP Mapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Mapper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testEmptyElementIfIsReference

 public function testEmptyElementIfIsReference()
 {
     $m = new Mapper($this->project);
     $m->setFrom("*.java");
     try {
         $m->setRefid(new Reference("dummyref"));
         $this->fail("Can add reference to Mapper with from attribute set");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
     $m = new Mapper($this->project);
     $m->setRefid(new Reference("dummyref"));
     try {
         $m->setFrom("*.java");
         $this->fail("Can set from in Mapper that is a reference.");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
     $m = new Mapper($this->project);
     $m->setRefid(new Reference("dummyref"));
     try {
         $m->setTo("*.java");
         $this->fail("Can set to in Mapper that is a reference.");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
     try {
         $m = new Mapper($this->project);
         $m->setRefid(new Reference("dummyref"));
         $m->setType("glob");
         $this->fail("Can set type in Mapper that is a reference.");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
 }
開發者ID:umesecke,項目名稱:phing,代碼行數:35,代碼來源:MapperTest.php

示例2: __construct

 public function __construct(Mapper $mapper, array $namespaces, array $paths)
 {
     $this->mapper = $mapper;
     $this->namespaces = $namespaces;
     $this->paths = $paths;
     $this->tables = $this->mapper->generate();
 }
開發者ID:block8,項目名稱:database,代碼行數:7,代碼來源:CodeGenerator.php

示例3: testMapperWithDefaultValue

 public function testMapperWithDefaultValue()
 {
     require_once __DIR__ . '/helpers/MapperTestDefaultHelper.php';
     $mapper = new Mapper();
     $class = $mapper->mapInputToCommand('MapperTestDefaultHelper', []);
     $this->assertEquals('456', $class->test);
 }
開發者ID:jildertmiedema,項目名稱:commander,代碼行數:7,代碼來源:MapperTest.php

示例4: login

 function login()
 {
     if (!empty($_POST)) {
         $check = new Check();
         $user = new User();
         $pdo = new Db();
         $db = $pdo->get();
         $mapper = new Mapper($db);
         //Проверяем входные данные
         $user->login = $check->checkInput($_POST['login']);
         $password = $check->checkInput($_POST['pass']);
         $user->password = md5($password);
         //Если пользователь не найден
         $this->user = $mapper->select($user);
         if (empty($this->user)) {
             $this->error = "Пароль или логин не совпадают";
             $this->out('login.php');
         } else {
             $this->out('profile.php');
             //Если найден, выводим профиль
         }
     } else {
         $this->out('login.php');
     }
 }
開發者ID:toppestkek,項目名稱:Test,代碼行數:25,代碼來源:ctrlIndex.php

示例5: add

 /**
  * Add file in given feed
  * @return bool
  */
 public static function add($feedID, $files, $ssh_connection)
 {
     // set permissions with the ssh connection
     // get feed path
     $mapper = new Mapper('Feed');
     $mapper->get($feedID);
     $resultsFeed = $mapper->get();
     $mapper = new Mapper('User');
     $mapper->get($resultsFeed['Feed'][0]->user_id);
     $resultsUser = $mapper->get();
     // target directory
     $dir = CHRIS_USERS . '/' . $resultsUser['User'][0]->username . '/file_browser/' . $resultsFeed['Feed'][0]->name . '-' . $resultsFeed['Feed'][0]->id . '/';
     $ssh_connection->exec('chmod 777 ' . $dir);
     foreach ($files as $key => $value) {
         $target_path = $dir . basename($value['name']);
         if (move_uploaded_file($value['tmp_name'], $target_path)) {
             // all good, set permissions correctly
             // not through ssh connection, do it as chris
             exec('chmod 775 ' . $target_path);
         } else {
             // oops.... something went wrong
             return $value['error'];
         }
         $ssh_connection->exec('chmod 755 ' . $dir);
     }
     // all files uploaded successfully
     return 0;
 }
開發者ID:masroore,項目名稱:chrisreloaded,代碼行數:32,代碼來源:file.controller.php

示例6: __construct

 /**
  * Constructor Method
  *
  * @param \Spot\Mapper $mapper
  * @throws Exception
  * @internal param $Spot_Mapper
  * @internal param string $entityName Name of the entity to query on/for
  */
 public function __construct(Mapper $mapper)
 {
     $this->_mapper = $mapper;
     $this->_entityName = $mapper->entity();
     $this->_tableName = $mapper->table();
     // Create Doctrine DBAL query builder from Doctrine\DBAL\Connection
     $this->_queryBuilder = $mapper->connection()->createQueryBuilder();
 }
開發者ID:surjit,項目名稱:spot2,代碼行數:16,代碼來源:Query.php

示例7: add

 /**
  * Add a <code>FileNameMapper</code>.
  * @param FileNameMapper $fileNameMapper a <code>FileNameMapper</code>.
  * @throws BadMethodCallException if attempting to add this
  *         <code>ContainerMapper</code> to itself, or if the specified
  *         <code>FileNameMapper</code> is itself a <code>ContainerMapper</code>
  *         that contains this <code>ContainerMapper</code>.
  */
 public function add(Mapper $fileNameMapper)
 {
     if ($this == $fileNameMapper || $fileNameMapper instanceof ContainerMapper && $fileNameMapper->contains($this)) {
         throw new BadMethodCallException("Circular mapper containment condition detected");
     } else {
         $this->mappers[] = $fileNameMapper;
     }
 }
開發者ID:Ingewikkeld,項目名稱:phing,代碼行數:16,代碼來源:ContainerMapper.php

示例8: savelike

 function savelike($like, $itemid)
 {
     $pdo = new Db();
     $db = $pdo->get();
     $mapper = new Mapper($db);
     $comments = new Comments();
     $comments->likes = $like;
     $comments->id = $itemid;
     $mapper->saveLike($comments);
 }
開發者ID:toppestkek,項目名稱:GuestBook,代碼行數:10,代碼來源:index.php

示例9: validate

 /**
  * Validate a token. Returns the result and deletes the token if valid.
  *
  * @param string $token The token
  * @return boolean
  */
 public static function validate($token)
 {
     $tokenMapper = new Mapper('Token');
     $tokenMapper->filter('value=(?)', $token);
     $tokenResults = $tokenMapper->get();
     if (count($tokenResults['Token']) == 0) {
         return false;
     }
     // we found the token
     Mapper::delete($tokenResults['Token'][0], $tokenResults['Token'][0]->id);
     return true;
 }
開發者ID:masroore,項目名稱:chrisreloaded,代碼行數:18,代碼來源:token.controller.php

示例10: writeOptionsFromObject

 /**
  * FormTools::WriteOptionsFromObject()
  * Prend en paramètres un nom d'objet et retourne un tableau
  * d'options de type:
  * <code>
  *         [0=>'<option value="1">Label1</option>',
  *          1=>'<option value="2">Label2</option>']
  * </code>
  *
  * @static
  * @param string $objname le nom de l'objet
  * @param mixed $selID la ou les valeurs selectionnées par défaut
  * @param mixed array or Filter: un filtre optionnel à appliquer
  * @param array $sort un tableau optionnel pour le tri
  * @param string $labelMethod la méthode à utiliser pour le label
  * @param array $fields les attributs à récupérer.
  * @param boolean $addNullEntry true pour ajouter une option 'Sélectionnez
  * un élément'
  * @return array the options array
  */
 static function writeOptionsFromObject($objname, $selID = 0, $filter = array(), $sort = array(), $labelmethod = 'toString', $fields = array(), $addNullEntry = false)
 {
     $options = array();
     $mapper = Mapper::singleton($objname);
     if (Tools::isException($mapper)) {
         return $mapper;
     }
     if ($labelmethod == 'toString') {
         $toStringAttribute = Tools::getToStringAttribute($objname);
         $fields = is_array($toStringAttribute) ? $toStringAttribute : array($toStringAttribute);
     }
     $col = $mapper->loadCollection($filter, $sort, $fields);
     if ($col instanceof Collection) {
         $dataArray = array();
         $count = $col->getCount();
         for ($i = 0; $i < $count; $i++) {
             $item = $col->getItem($i);
             if (method_exists($item, 'getId') && method_exists($item, $labelmethod)) {
                 $dataArray[$item->getId()] = $item->{$labelmethod}();
             }
             unset($item);
         }
         $options = FormTools::writeOptionsFromArray($dataArray, $selID, $addNullEntry);
     }
     return $options;
 }
開發者ID:arhe,項目名稱:pwak,代碼行數:46,代碼來源:Form.php

示例11: write

 public static function write($name, $value, $expires = null)
 {
     $self = self::getInstance();
     $expires = $self->expire($expires);
     $path = Mapper::normalize(Mapper::base() . $self->path);
     return setcookie($self->name . '[' . $name . ']', self::encrypt($value), $expires, $path, $self->domain, $self->secure);
 }
開發者ID:klawdyo,項目名稱:spaghettiphp,代碼行數:7,代碼來源:Cookie.php

示例12: verifySettings

 /**
  * Checks to make sure all settings are kosher. In this case, it
  * means that the dest attribute has been set and we have a mapper.
  */
 public function verifySettings()
 {
     if ($this->targetdir === null) {
         $this->setError("The targetdir attribute is required.");
     }
     if ($this->map === null) {
         if ($this->mapperElement === null) {
             $this->map = new IdentityMapper();
         } else {
             $this->map = $this->mapperElement->getImplementation();
             if ($this->map === null) {
                 $this->setError("Could not set <mapper> element.");
             }
         }
     }
 }
開發者ID:Geeklog-Japan,項目名稱:geeklog-japan,代碼行數:20,代碼來源:MappingSelector.php

示例13: getComputed

 /**
  * Returns lazy loaded field by its name
  *
  * @param string $fieldName
  * @return mixed
  */
 public function getComputed($fieldName)
 {
     if (!isset($this->computed[$fieldName])) {
         $value = $this->mapper->lazyload($this, $fieldName);
         $this->computed[$fieldName] = $value;
     }
     return $this->computed[$fieldName];
 }
開發者ID:emoveo,項目名稱:sfm,代碼行數:14,代碼來源:Business.php

示例14: registerAdapter

 public function registerAdapter($name, Adapter $adapter)
 {
     if (isset($this->adapters[$name])) {
         throw new Exception\InvalidArgumentException("Adapter with name " . $name . " already registered!");
     }
     $this->adapters[$name] = $adapter;
     if ($adapter->getMapping()) {
         $this->mapper->registerAdapterMapping($name, $adapter->getMapping());
     }
 }
開發者ID:bauer01,項目名稱:unimapper,代碼行數:10,代碼來源:Connection.php

示例15: get

 public function get(array $hashMap, $isNestedKeysName = false)
 {
     $pattern = $this->getPattern($isNestedKeysName);
     $this->mapper->match($pattern, [$hashMap]);
     $data = $this->mapper->current();
     if (empty($data)) {
         $result = $this->getEmptyArray($pattern);
     } else {
         $result = $this->arrayHelper->toTuple($data, $pattern);
     }
     return $result;
 }
開發者ID:angrybender,項目名稱:phpPM,代碼行數:12,代碼來源:Assign.php


注:本文中的Mapper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。