3 edited tags
| link
2 added 8 tag, formatting fix
source | link

Drupal 8 How to Query MySQL Database Module

Could you help help me correct the follow piece of code

I am getting the following error.

"The website encountered an unexpected error. Please try again later."

*

public function __construct(Connection $connection) {
    $this->connection = Database::getConnection();
  }
public function hello($state = '0') {
    $sqlQuery = $connection->select('pop11', 'C2011')
    ->fields('C2011', array('male', 'female'))
    ->condition('C2011.sCode', '10', '=');
    $data = $sqlQuery->execute();        
    if ($data) {
        $results = $data->fetchAll(\PDO::FETCH_OBJ);
        foreach ($results as $row) {
        echo "Field a: {$row->male}, field b: {$row->female}";
        }            
    }else{
        return array('#title' => 'Error', '#markup' => 'Could not Find. What you are Looking for.',);
    }

}

}*

Drupal 8 How to Query MySQL Database Module

Could you help help me correct the follow piece of code

I am getting the following error.

"The website encountered an unexpected error. Please try again later."

*

public function __construct(Connection $connection) {
    $this->connection = Database::getConnection();
  }
public function hello($state = '0') {
    $sqlQuery = $connection->select('pop11', 'C2011')
    ->fields('C2011', array('male', 'female'))
    ->condition('C2011.sCode', '10', '=');
    $data = $sqlQuery->execute();        
    if ($data) {
        $results = $data->fetchAll(\PDO::FETCH_OBJ);
        foreach ($results as $row) {
        echo "Field a: {$row->male}, field b: {$row->female}";
        }            
    }else{
        return array('#title' => 'Error', '#markup' => 'Could not Find. What you are Looking for.',);
    }

}

}*

How to Query MySQL Database Module

Could you help help me correct the follow piece of code

I am getting the following error.

"The website encountered an unexpected error. Please try again later."

public function __construct(Connection $connection) {
    $this->connection = Database::getConnection();
  }
public function hello($state = '0') {
    $sqlQuery = $connection->select('pop11', 'C2011')
    ->fields('C2011', array('male', 'female'))
    ->condition('C2011.sCode', '10', '=');
    $data = $sqlQuery->execute();        
    if ($data) {
        $results = $data->fetchAll(\PDO::FETCH_OBJ);
        foreach ($results as $row) {
        echo "Field a: {$row->male}, field b: {$row->female}";
        }            
    }else{
        return array('#title' => 'Error', '#markup' => 'Could not Find. What you are Looking for.',);
    }

}
1
source | link

Drupal 8 How to Query MySQL Database Module

Could you help help me correct the follow piece of code

I am getting the following error.

"The website encountered an unexpected error. Please try again later."

*

public function __construct(Connection $connection) {
    $this->connection = Database::getConnection();
  }
public function hello($state = '0') {
    $sqlQuery = $connection->select('pop11', 'C2011')
    ->fields('C2011', array('male', 'female'))
    ->condition('C2011.sCode', '10', '=');
    $data = $sqlQuery->execute();        
    if ($data) {
        $results = $data->fetchAll(\PDO::FETCH_OBJ);
        foreach ($results as $row) {
        echo "Field a: {$row->male}, field b: {$row->female}";
        }            
    }else{
        return array('#title' => 'Error', '#markup' => 'Could not Find. What you are Looking for.',);
    }

}

}*