Пример #1
0
 public function testDump()
 {
     $testContent = "Foo Content";
     $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'propel_test_' . microtime();
     $parser = PropelParser::getParser('XML');
     $parser->dump($testContent, $testFile);
     $content = file_get_contents($testFile);
     $this->assertEquals($testContent, $content);
     unlink($testFile);
 }
Пример #2
0
 /**
  * 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 PropelOnDemandCollection cannot be exported. Any attempt will result in a PropelExecption being thrown.
  *
  * @param     mixed   $parser                 A PropelParser 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 PropelArrayCollection, as PropelArrayFormatter 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 PropelArrayCollection, as PropelArrayFormatter 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 PropelParser) {
         $parser = PropelParser::getParser($parser);
     }
     return $parser->listFromArray($this->toArray(null, $usePrefix, BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns));
 }
Пример #3
0
 /**
  * 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 PropelParser 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 PropelParser) {
         $parser = PropelParser::getParser($parser);
     }
     return $parser->fromArray($this->toArray(BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
 }