本文整理匯總了PHP中Magento\Framework\Model\Resource\Db\AbstractDb::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractDb::load方法的具體用法?PHP AbstractDb::load怎麽用?PHP AbstractDb::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Model\Resource\Db\AbstractDb
的用法示例。
在下文中一共展示了AbstractDb::load方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
示例2: 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 (is_null($field) && !is_numeric($value)) {
$field = 'code';
}
return parent::load($object, $value, $field);
}
示例3: 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\Resource\Db\AbstractDb
*/
public function load(AbstractModel $object, $value, $field = null)
{
if (is_numeric($value)) {
return parent::load($object, $value);
} else {
$this->loadByQuery($object, $value);
}
return $this;
}
示例4: 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\\Resource\\Db\\AbstractDb', '_idFieldName');
$idFieldName->setAccessible(true);
$idFieldName->setValue($this->_model, 'field_value');
$this->assertInstanceOf('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', $this->_model->load($abstractModelMock, $value, $idFieldName));
}
示例5: 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->_getReadAdapter()->select()->from($this->getMainTable())->where($this->getMainTable() . '.string=:tr_string');
$result = $this->_getReadAdapter()->fetchRow($select, array('tr_string' => $value));
$object->setData($result);
$this->_afterLoad($object);
return $result;
} else {
return parent::load($object, $value, $field);
}
}
示例6: load
public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
{
return parent::load($object, $value, $field);
}