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


PHP Column::isLazyLoad方法代码示例

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


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

示例1: addTemporalMutator

 /**
  * Adds a setter method for date/time/timestamp columns.
  * @param      string &$script The script will be modified in this method.
  * @param      Column $col The current column.
  * @see        parent::addColumnMutators()
  */
 protected function addTemporalMutator(&$script, Column $col)
 {
     $cfc = $col->getPhpName();
     $clo = strtolower($col->getName());
     $visibility = $col->getMutatorVisibility();
     $dateTimeClass = $this->getBuildProperty('dateTimeClass');
     if (!$dateTimeClass) {
         $dateTimeClass = 'DateTime';
     }
     $this->declareClasses($dateTimeClass);
     $script .= "\n\t/**\n\t * Sets the value of [{$clo}] column to a normalized version of the date/time value specified.\n\t * " . $col->getDescription() . "\n\t * @param      mixed \$v string, integer (timestamp), or DateTime value.  Empty string will\n\t *\t\t\t\t\t\tbe treated as NULL for temporal objects.\n\t * @return     " . $this->getObjectClassname() . " The current object (for fluent API support)\n\t */\n\t" . $visibility . " function set{$cfc}(\$v)\n\t{";
     if ($col->isLazyLoad()) {
         $script .= "\n\t\t// explicitly set the is-loaded flag to true for this lazy load col;\n\t\t// it doesn't matter if the value is actually set or not (logic below) as\n\t\t// any attempt to set the value means that no db lookup should be performed\n\t\t// when the get{$cfc}() method is called.\n\t\t\$this->" . $clo . "_isLoaded = true;\n";
     }
     $fmt = var_export($this->getTemporalFormatter($col), true);
     $script .= "\n\t\t// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')\n\t\t// -- which is unexpected, to say the least.\n\t\tif (\$v === null || \$v === '') {\n\t\t\t\$dt = null;\n\t\t} elseif (\$v instanceof DateTime) {\n\t\t\t\$dt = \$v;\n\t\t} else {\n\t\t\t// some string/numeric value passed; we normalize that so that we can\n\t\t\t// validate it.\n\t\t\ttry {\n\t\t\t\tif (is_numeric(\$v)) { // if it's a unix timestamp\n\t\t\t\t\t\$dt = new {$dateTimeClass}('@'.\$v, new DateTimeZone('UTC'));\n\t\t\t\t\t// We have to explicitly specify and then change the time zone because of a\n\t\t\t\t\t// DateTime bug: http://bugs.php.net/bug.php?id=43003\n\t\t\t\t\t\$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));\n\t\t\t\t} else {\n\t\t\t\t\t\$dt = new {$dateTimeClass}(\$v);\n\t\t\t\t}\n\t\t\t} catch (Exception \$x) {\n\t\t\t\tthrow new PropelException('Error parsing date/time value: ' . var_export(\$v, true), \$x);\n\t\t\t}\n\t\t}\n\n\t\tif ( \$this->{$clo} !== null || \$dt !== null ) {\n\t\t\t// (nested ifs are a little easier to read in this case)\n\n\t\t\t\$currNorm = (\$this->{$clo} !== null && \$tmpDt = new {$dateTimeClass}(\$this->{$clo})) ? \$tmpDt->format({$fmt}) : null;\n\t\t\t\$newNorm = (\$dt !== null) ? \$dt->format({$fmt}) : null;\n\n\t\t\tif ( (\$currNorm !== \$newNorm) // normalized values don't match ";
     if (($def = $col->getDefaultValue()) !== null && !$def->isExpression()) {
         $defaultValue = $this->getDefaultValueString($col);
         $script .= "\n\t\t\t\t\t|| (\$dt->format({$fmt}) === {$defaultValue}) // or the entered value matches the default";
     }
     $script .= "\n\t\t\t\t\t)\n\t\t\t{\n\t\t\t\t\$this->{$clo} = (\$dt ? \$dt->format({$fmt}) : null);\n\t\t\t\t\$this->modifiedColumns[] = " . $this->getColumnConstant($col) . ";\n\t\t\t}\n\t\t} // if either are not null\n";
     $this->addMutatorClose($script, $col);
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:29,代码来源:PHP5ObjectBuilder.php

示例2: addRemoveArrayElement

 /**
  * Adds a remove method for an array column.
  * @param      string &$script The script will be modified in this method.
  * @param      Column $col The current column.
  */
 protected function addRemoveArrayElement(&$script, Column $col)
 {
     $clo = strtolower($col->getName());
     $cfc = $col->getPhpName();
     $visibility = $col->getAccessorVisibility();
     $singularPhpName = rtrim($cfc, 's');
     $script .= "\n\t/**\n\t * Removes a value from the [{$clo}] array column value.\n\t * @param      mixed \$value\n\t * " . $col->getDescription();
     if ($col->isLazyLoad()) {
         $script .= "\n\t * @param      PropelPDO An optional PropelPDO connection to use for fetching this lazy-loaded column.";
     }
     $script .= "\n\t * @return     " . $this->getObjectClassname() . " The current object (for fluent API support)\n\t */\n\t{$visibility} function remove{$singularPhpName}(\$value";
     if ($col->isLazyLoad()) {
         $script .= ", PropelPDO \$con = null";
     }
     // we want to reindex the array, so array_ functions are not the best choice
     $script .= ")\n\t{\n\t\t\$targetArray = array();\n\t\tforeach (\$this->get{$cfc}(";
     if ($col->isLazyLoad()) {
         $script .= "\$con";
     }
     $script .= ") as \$element) {\n\t\t\tif (\$element != \$value) {\n\t\t\t\t\$targetArray []= \$element;\n\t\t\t}\n\t\t}\n\t\t\$this->set{$cfc}(\$targetArray);\n\n\t\treturn \$this;\n\t} // remove{$singularPhpName}()\n";
 }
开发者ID:halfer,项目名称:Meshing,代码行数:26,代码来源:PHP5ObjectBuilder.php

示例3: addMutatorOpen

 /**
  * Adds the open of the mutator (setter) method for a column.
  * @param      string &$script The script will be modified in this method.
  * @param      Column $col The current column.
  */
 protected function addMutatorOpen(&$script, Column $col)
 {
     $cfc = $col->getPhpName();
     $clo = strtolower($col->getName());
     $script .= "\n\t/**\n\t * Set the value of [{$clo}] column.\n\t * " . $col->getDescription() . "\n\t * @param      " . $col->getPhpNative() . " \$v new value\n\t * @return     void\n\t */\n\tpublic function set{$cfc}(\$v)\n\t{\n";
     if ($col->isLazyLoad()) {
         $script .= "\n\t\t// explicitly set the is-loaded flag to true for this lazy load col;\n\t\t// it doesn't matter if the value is actually set or not (logic below) as\n\t\t// any attempt to set the value means that no db lookup should be performed\n\t\t// when the get{$cfc}() method is called.\n\t\t\$this->" . $clo . "_isLoaded = true;\n";
     }
 }
开发者ID:taryono,项目名称:school,代码行数:14,代码来源:PHP5BasicObjectBuilder.php


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