- if ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
- return array('nickname' => $row['nickname'],
- 'name' => "$row[firstname] $row[lastname]",
- 'firstname' => $row['firstname'],
- 'lastname' => $row['lastname'],
- 'email' => $row['email'],
- 'label' => $row['label'],
- 'backend' => $this->bnum,
- 'source' => &$this->sname);
+ global $use_pdo, $pdo_show_sql_errors;
+ if ($use_pdo) {
+ if (!($sth = $this->dbh->prepare('SELECT * FROM ' . $this->identifier_quote_char . $this->table . $this->identifier_quote_char . ' WHERE ' . $this->identifier_quote_char . 'owner' . $this->identifier_quote_char . ' = ? AND LOWER(' . $this->identifier_quote_char . $db_field . $this->identifier_quote_char . ') = ?'))) {
+ if ($pdo_show_sql_errors)
+ return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh->errorInfo())));
+ else
+ return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
+ }
+ if (!($res = $sth->execute(array($this->owner, $value)))) {
+ if ($pdo_show_sql_errors)
+ return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
+ else
+ return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
+ }
+
+ if ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
+ return array('nickname' => $row['nickname'],
+ 'name' => $this->fullname($row['firstname'], $row['lastname']),
+ 'firstname' => $row['firstname'],
+ 'lastname' => $row['lastname'],
+ 'email' => $row['email'],
+ 'label' => $row['label'],
+ 'backend' => $this->bnum,
+ 'source' => &$this->sname);
+ }
+
+ } else {
+ $query = sprintf("SELECT * FROM %s WHERE owner = '%s' AND LOWER(%s) = '%s'",
+ $this->table, $this->owner, $db_field,
+ $this->dbh->quoteString($value));
+
+ $res = $this->dbh->query($query);
+
+ if (DB::isError($res)) {
+ return $this->set_error(sprintf(_("Database error: %s"),
+ DB::errorMessage($res)));
+ }
+
+ if ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
+ return array('nickname' => $row['nickname'],
+ 'name' => $this->fullname($row['firstname'], $row['lastname']),
+ 'firstname' => $row['firstname'],
+ 'lastname' => $row['lastname'],
+ 'email' => $row['email'],
+ 'label' => $row['label'],
+ 'backend' => $this->bnum,
+ 'source' => &$this->sname);
+ }