Skip to content

Database SimplePdo #726

Description

@siaupheng

hi,

i have problem when using SimplePdo with method fetchField().
when the query return empty record, that method raise the error "Call to a member function getData() on null".

i think the better is have result checking before call getData(), like this :

public function fetchField(string $sql, array $params = [])
{
      $result = $this->fetchRow($sql, $params);
      if (!$result) return false; //this checking the result is not null and return false
      $data = $result->getData();
      return reset($data);
 }

thank you.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions