本文整理匯總了PHP中Zend_Ldap::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Ldap::save方法的具體用法?PHP Zend_Ldap::save怎麽用?PHP Zend_Ldap::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Ldap
的用法示例。
在下文中一共展示了Zend_Ldap::save方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
/**
* Save new set of data from a t41_Data_Object object
*
* @param t41_Data_Object $do
* @return boolean
* @throws t41_Backend_Exception
*/
public function create(ObjectModel\DataObject $do)
{
$pkey = $this->_mapper ? $this->_mapper->getPrimaryKey($do->getClass()) : 'uid';
$recordSet = $do->toArray($this->_uri->getAlias());
// get a valid data array passing mapper if any
if ($this->_mapper) {
// get object class
$objectClass = $this->_mapper->getDataclass($do->getClass());
$subDn = $this->_mapper->getDatastore($do->getClass());
$recordSet = $do->map($this->_mapper, $this->_uri->getAlias());
} else {
/*
* If no mapper is available, LDAP objectClass is supposed to be the same as PHP object class
* CN is a MD5 hash of recordSet
*/
$objectClass = $do->getClass();
$subDn = null;
}
$recordSet['data']['objectClass'] = $objectClass;
try {
if (!$this->_ressource) {
$this->_connect($subDn);
}
// Define unique part of the record DN
// If no value is specified, get a unique identifier
$dn = sprintf('%s=%s', $pkey, isset($recordSet['data'][$pkey]) ? $recordSet['data'][$pkey] : $this->_getIdentifier($this->_mapper->getDatastore($do->getClass())));
// Datastore value may contain supplemental path like 'ou=...'
if (($ou = $this->_mapper->getDatastore($do->getClass())) != null) {
$dn = $dn . ',' . $ou;
}
$dn .= ',' . $this->_baseDN;
$this->_ressource->save($dn, $recordSet['data']);
} catch (Exception $e) {
// @todo decide wether throw an exception or just save last message in a property
die($e->getMessage());
return false;
}
$uri = new ObjectModel\ObjectUri();
$do->setUri($this->getAlias() . '/' . $dn);
/* get collection handling properties (if any) and process them */
foreach ($do->getProperties() as $property) {
if (!$property instanceof Property\CollectionProperty) {
continue;
}
$collection = $property->getValue();
var_dump($collection->getMembers());
/* @var $member t41_Object_Model */
foreach ($collection->getMembers() as $member) {
$member->setProperty($property->getParameter('keyprop'), $uri);
$member->save();
}
}
return true;
}