You are here

public static function CartStorage::load in Basic cart 8.6

Same name and namespace in other branches
  1. 8 src/CartStorage.php \Drupal\basic_cart\CartStorage::load()
  2. 8.0 src/CartStorage.php \Drupal\basic_cart\CartStorage::load()
  3. 8.2 src/CartStorage.php \Drupal\basic_cart\CartStorage::load()
  4. 8.3 src/CartStorage.php \Drupal\basic_cart\CartStorage::load()
  5. 8.4 src/CartStorage.php \Drupal\basic_cart\CartStorage::load()
  6. 8.5 src/CartStorage.php \Drupal\basic_cart\CartStorage::load()

Read from the Cart data from database.

Parameters

array $entry: An array containing all the fields used to search the entries in the table.

Return value

object An object containing the loaded entries if found.

See also

db_select()

db_query()

http://drupal.org/node/310072

http://drupal.org/node/310075

File

src/CartStorage.php, line 116

Class

CartStorage
Class CartStorage.

Namespace

Drupal\basic_cart

Code

public static function load(array $entry = array()) {

  // Read all fields from the dbtng_example table.
  // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
  // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
  $select = \Drupal::database()
    ->select(self::TABLE, 'cart');
  $select
    ->fields('cart');

  // Add each field and value as a condition to this query.
  foreach ($entry as $field => $value) {
    $select
      ->condition($field, $value);
  }

  // Return the result in object format.
  return $select
    ->execute()
    ->fetchAll();
}