本文整理汇总了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;
}