<?php
namespace front\factory;

class Scontainers
{
  public static function scontainer_details( $scontainer_id )
  {
    global $mdb, $lang;
    
    if ( !$scontainer = \Cache::fetch( "scontainer_details:$scontainer_id:" . $lang[0] ) )
    {    
      $scontainer = $mdb -> get( 'pp_scontainers', '*', [ 'id' => (int)$scontainer_id ] );

      $results = $mdb -> select( 'pp_scontainers_langs', '*', [ 'AND' => [ 'container_id' => (int)$scontainer_id, 'lang_id' => $lang[0] ] ] );
      if ( is_array( $results ) ) foreach ( $results as $row )
        $scontainer['languages'] = $row;
      
      \Cache::store( "scontainer_details:$scontainer_id:" . $lang[0], $scontainer );
    }
    
    return $scontainer;
  }
}
