Exemple #1
0
 public function read(Hive $parent)
 {
     $child = Hive::factory($this->model, array($this->parent => $parent));
     if ($parent->prepared()) {
         foreach ($this->using as $local => $remote) {
             $child->{$remote} = $parent->{$local};
         }
     }
     if ($this->conditions) {
         foreach ($this->conditions as $remote => $value) {
             $child->{$remote} = $value;
         }
     }
     return $child;
 }
Exemple #2
0
 public function read(Hive $parent)
 {
     $container = Hive_Container::factory($parent, $this);
     if ($parent->prepared()) {
         // Create child model
         $child = Hive::factory($this->model);
         // Import meta data
         $parent_meta = Hive::meta($parent);
         $child_meta = Hive::meta($child);
         // Create a new query
         $query = $child->query_select();
         // Apply JOINs
         $query->join($this->table);
         foreach ($this->using['child'] as $local => $remote) {
             $query->on($child_meta->column($local), '=', "{$this->table}.{$remote}");
         }
         foreach ($this->using['parent'] as $local => $remote) {
             $query->where("{$this->table}.{$remote}", '=', $parent->{$local});
         }
         // Return the result as an array of child objects
         $results = $query->as_object($child)->execute($parent_meta->db)->as_array($this->key);
         $container->values($results);
     }
     return $container;
 }
Exemple #3
0
 public function __construct($db = null)
 {
     if (!$db) {
         $this->db = \Zend_Db::factory('Pdo_Mysql', Database::getDbParams());
     } else {
         $this->db = $db;
     }
     global $argv;
     $options = array();
     $options['task_name'] = $argv[1];
     $taskOptions = $argv[2];
     $temp = explode(";", $taskOptions);
     foreach ($temp as $k => $v) {
         $newPair = explode("=", $v);
         $options[$newPair[0]] = $newPair[1];
     }
     $hive = new Hive($this);
     $hive->run($options);
 }
Exemple #4
0
 public function read(Hive $parent)
 {
     $container = Hive_Container::factory($parent, $this);
     if ($parent->prepared()) {
         // Create child model
         $child = Hive::factory($this->model);
         // Import meta data
         $parent_meta = Hive::meta($parent);
         $child_meta = Hive::meta($child);
         // Create a new query
         $query = $child->query_select();
         // Apply JOINs
         $query->join($parent_meta->table);
         foreach ($this->using as $parent_field => $child_field) {
             $query->on($parent_meta->column($parent_field), '=', $child_meta->column($child_field));
         }
         // Apply parent WHERE conditions
         $parent->query_conditions($query);
         // Return the result as an array of child objects
         $results = $query->as_object($child)->execute($parent_meta->db)->as_array($this->key);
         $container->values($results);
     }
     return $container;
 }