/** * Prepare SQL and load one or more records. * * @return mixed */ public function execute() { $select_sql = $this->getSelectSql(); if ($this->loadByTypeField()) { $return_by = ConnectionInterface::RETURN_OBJECT_BY_FIELD; $return_by_value = 'type'; } else { $return_by = ConnectionInterface::RETURN_OBJECT_BY_CLASS; $return_by_value = $this->type; } if ($this->hasContainer()) { return $this->connection->advancedExecute($select_sql, null, ConnectionInterface::LOAD_ALL_ROWS, $return_by, $return_by_value, [&$this->connection, &$this->pool, &$this->log], $this->getContainer()); } else { return $this->connection->advancedExecute($select_sql, null, ConnectionInterface::LOAD_ALL_ROWS, $return_by, $return_by_value, [&$this->connection, &$this->pool, &$this->log]); } }
/** * {@inheritdoc} */ public function findBySql($type, $sql, ...$arguments) { if (empty($type)) { throw new InvalidArgumentException('Type is required'); } if (empty($sql)) { throw new InvalidArgumentException('SQL statement is required'); } if ($registered_type = $this->getRegisteredType($type)) { if (in_array('type', $this->getTypeFields($type))) { $return_by = ConnectionInterface::RETURN_OBJECT_BY_FIELD; $return_by_value = 'type'; } else { $return_by = ConnectionInterface::RETURN_OBJECT_BY_CLASS; $return_by_value = $type; } return $this->connection->advancedExecute($sql, $arguments, ConnectionInterface::LOAD_ALL_ROWS, $return_by, $return_by_value, [&$this->connection, &$this, &$this->log]); } else { throw new InvalidArgumentException("Type '{$type}' is not registered"); } }