本文整理汇总了PHP中Propel\Runtime\Parser\AbstractParser::getParser方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractParser::getParser方法的具体用法?PHP AbstractParser::getParser怎么用?PHP AbstractParser::getParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\Parser\AbstractParser
的用法示例。
在下文中一共展示了AbstractParser::getParser方法的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);
}
示例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));
}
示例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;
}
示例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));
}