本文整理汇总了PHP中Magento\Framework\Model\ResourceModel\Db\AbstractDb::load方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractDb::load方法的具体用法?PHP AbstractDb::load怎么用?PHP AbstractDb::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\ResourceModel\Db\AbstractDb
的用法示例。
在下文中一共展示了AbstractDb::load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Load an object using 'product_id' field if there's no field specified and value is not numeric
*
* @param AbstractModel|\Sebwite\ProductDownloads\Model\Download $object
* @param mixed $value
* @param string $field
*
* @return $this
*/
public function load(AbstractModel $object, $value, $field = null)
{
if (!is_numeric($value) && is_null($field)) {
$field = 'product_id';
}
return parent::load($object, $value, $field);
}
示例2: load
/**
* Load an object using 'url_key' field if there's no field specified and value is not numeric
*
* @param \Magento\Framework\Model\AbstractModel $object
* @param mixed $value
* @param string $field
* @return $this
*/
public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
{
if (!is_numeric($value) && is_null($field)) {
$field = 'url_key';
}
return parent::load($object, $value, $field);
}
示例3: load
/**
* Load an object
*
* @param FormType|AbstractModel $object
* @param mixed $value
* @param string $field field to load by (defaults to model id)
* @return $this
*/
public function load(AbstractModel $object, $value, $field = null)
{
if ($field === null && !is_numeric($value)) {
$field = 'code';
}
return parent::load($object, $value, $field);
}
示例4: load
/**
* Loading string as a value or regular numeric
*
* @param AbstractModel $object
* @param int|string $value
* @param null|string $field
* @return $this|\Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @SuppressWarnings("unused")
*/
public function load(AbstractModel $object, $value, $field = null)
{
if (is_numeric($value)) {
return parent::load($object, $value);
} else {
$this->loadByQuery($object, $value);
}
return $this;
}
示例5: testLoad
public function testLoad()
{
$contextMock = $this->getMock('\\Magento\\Framework\\Model\\Context', [], [], '', false);
$registryMock = $this->getMock('\\Magento\\Framework\\Registry', [], [], '', false);
$abstractModelMock = $this->getMockForAbstractClass('\\Magento\\Framework\\Model\\AbstractModel', [$contextMock, $registryMock], '', false, true, true, ['__wakeup']);
$value = 'some_value';
$idFieldName = new \ReflectionProperty('Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb', '_idFieldName');
$idFieldName->setAccessible(true);
$idFieldName->setValue($this->_model, 'field_value');
$this->assertInstanceOf('Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb', $this->_model->load($abstractModelMock, $value, $idFieldName));
}
示例6: load
/**
* Load
*
* @param \Magento\Framework\Model\AbstractModel $object
* @param String $value
* @param String $field
* @return array|$this
*/
public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
{
if (is_string($value)) {
$select = $this->getConnection()->select()->from($this->getMainTable())->where($this->getMainTable() . '.string=:tr_string');
$result = $this->getConnection()->fetchRow($select, ['tr_string' => $value]);
$object->setData($result);
$this->_afterLoad($object);
return $result;
} else {
return parent::load($object, $value, $field);
}
}
示例7: load
/**
* @param \Magento\Framework\Model\AbstractModel $object
* @param mixed $value
* @param null $field
*
* @return $this
*/
public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
{
return parent::load($object, $value, $field);
}