- Some more bugfixes and added the OrganizationalUnit entity

This commit is contained in:
mcndave committed 2021-03-09 15:26:15 +00:00
1 parent 8d1a310921
commit fa806e8e0d
11 files changed
+173 -158

No files matched your search

+6 -56
View File
@@ -64,9 +64,9 @@ class LdapObject {
public function select(array $filter, array $fields = [])
{
static::$dump && call_user_func_array(static::$dump, [ $sql, $parameters ]);
static::$dump && call_user_func_array(static::$dump, [ $filter, $fields ]);
$this->search = ldap_search($this->connection, $this->dn, $filter['filters'], $filter['fields'], 0, $filter['limit'] ?? -1);
$this->search = ldap_search($this->connection, $this->dn, $filter['filters'], $filter['fields'], 0, 0);
$this->rowCount = $this->bufferedRows = ldap_count_entries($this->connection, $this->search);
@@ -75,18 +75,20 @@ class LdapObject {
public function fetch() /* : bool|array */
{
static $result;
if (! $this->search ) {
throw new \Exception('Impossible to fetch from LdapObject from which select() was not called first.');
}
if ( ! $this->bufferedRows ) {
return false;
return $result = false;
}
if ( $this->rowCount === $this->bufferedRows ) {
$result = ldap_first_entry($this->connection, $this->search);
}
else {
$result = ldap_next_entry($this->connection, $this->search);
$result = ldap_next_entry($this->connection, $result);
}
if ($result) {
@@ -119,56 +121,4 @@ class LdapObject {
}
public function closeCursor() : void {}
public function runQuery(string $sql, array $parameters = [])
{
static::$dump && call_user_func_array(static::$dump, [ $sql, $parameters ]);
try {
if (false !== ( $statement = $this->prepare($sql) )) {
return $this->execute($statement, $parameters, true);
}
}
catch (\PDOException $e) {
throw new \PdoException($e->getMessage() . " `$sql` with data:" . json_encode($parameters));
}
return null;
}
public function execute(PDOStatement $statement, array $parameters = [], bool $commit = true)
{
try {
if ( ! $this->inTransaction() ) {
$this->beginTransaction();
}
if (empty($parameters) ? $statement->execute() : $statement->execute($parameters)) {
$statement->lastInsertId = $this->lastInsertId();
if ( $commit ) {
$this->commit();
}
return $statement;
}
else {
throw new \PDOException($statement->errorCode() . " - " . json_encode($statement->errorInfo()));
}
}
catch (\PDOException $e) {
$this->rollback();
throw $e;
}
catch (\Throwable $e) {
if ( function_exists("debogueur") ) {
debogueur($statement, $parameters, $commit);
}
throw $e;
}
return null;
}
}