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


PHP Parser\AbstractParser類代碼示例

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


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

示例1: testDump

 public function testDump()
 {
     $testContent = "Foo Content";
     $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'propel_test_' . microtime();
     $parser = AbstractParser::getParser('XML');
     $parser->dump($testContent, $testFile);
     $content = file_get_contents($testFile);
     $this->assertEquals($testContent, $content);
     unlink($testFile);
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:10,代碼來源:AbstractParserTest.php

示例2: exportTo

 /**
  * Export the current object properties to a string, using a given parser format
  * <code>
  * $book = BookQuery::create()->findPk(9012);
  * echo $book->exportTo('JSON');
  *  => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
  * </code>
  *
  * @param  mixed   $parser                 A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
  * @param  boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
  * @return string  The exported data
  */
 public function exportTo($parser, $includeLazyLoadColumns = true)
 {
     if (!$parser instanceof AbstractParser) {
         $parser = AbstractParser::getParser($parser);
     }
     return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
 }
開發者ID:vigourouxjulien,項目名稱:thelia,代碼行數:19,代碼來源:CouponVersion.php

示例3: importFrom

 /**
  * Populate the current object from a string, using a given parser format
  * <code>
  * $book = new Book();
  * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
  * </code>
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
  * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  * The default key type is the column's TableMap::TYPE_PHPNAME.
  *
  * @param mixed $parser A AbstractParser instance,
  *                       or a format name ('XML', 'YAML', 'JSON', 'CSV')
  * @param string $data The source data to import from
  * @param string $keyType The type of keys the array uses.
  *
  * @return $this|\JaCategorias The current object, for fluid interface
  */
 public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME)
 {
     if (!$parser instanceof AbstractParser) {
         $parser = AbstractParser::getParser($parser);
     }
     $this->fromArray($parser->toArray($data), $keyType);
     return $this;
 }
開發者ID:alejandrososa,項目名稱:angularja,代碼行數:27,代碼來源:JaCategorias.php

示例4: exportTo

 /**
  * Export the current collection to a string, using a given parser format
  * <code>
  * $books = BookQuery::create()->find();
  * echo $book->exportTo('JSON');
  *  => {{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}');
  * </code>
  *
  * A OnDemandCollection cannot be exported. Any attempt will result in a PropelException being thrown.
  *
  * @param mixed   $parser    A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
  * @param boolean $usePrefix (optional) If true, the returned element keys will be prefixed with the
  *                                            model class name ('Article_0', 'Article_1', etc). Defaults to TRUE.
  *                                            Not supported by ArrayCollection, as ArrayFormatter has
  *                                            already created the array used here with integers as keys.
  * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
  *                                            Not supported by ArrayCollection, as ArrayFormatter has
  *                                            already included lazy-load columns in the array used here.
  * @return string The exported data
  */
 public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = true)
 {
     if (!$parser instanceof AbstractParser) {
         $parser = AbstractParser::getParser($parser);
     }
     return $parser->listFromArray($this->toArray(null, $usePrefix, TableMap::TYPE_PHPNAME, $includeLazyLoadColumns));
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:27,代碼來源:Collection.php


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