Új hozzászólás Aktív témák

  • Sk8erPeter

    nagyúr

    válasz Peter Kiss #8 üzenetére

    "mi volt a tesztkörnyezet"
    Itt eléggé pontatlan volt, amit írtam, mert nem csak a konfiguráció érdekelt volna, hanem a konkrét kód.

    A Kohanás kódra:
    igazából abbahagytam a bemásolást, és nem raktam be azt, amit még kellett volna: a _load_result() függvényt:

    ..............
    /**
    * Loads a database result, either as a new record for this model, or as
    * an iterator for multiple rows.
    *
    * @chainable
    * @param bool $multiple Return an iterator or load a single row
    * @return ORM|Database_Result
    */
    protected function _load_result($multiple = FALSE)
    {
    $this->_db_builder->from(array($this->_table_name, $this->_object_name));

    if ($multiple === FALSE)
    {
    // Only fetch 1 record
    $this->_db_builder->limit(1);
    }

    // Select all columns by default
    $this->_db_builder->select($this->_object_name.'.*');

    if ( ! isset($this->_db_applied['order_by']) AND ! empty($this->_sorting))
    {
    foreach ($this->_sorting as $column => $direction)
    {
    if (strpos($column, '.') === FALSE)
    {
    // Sorting column for use in JOINs
    $column = $this->_object_name.'.'.$column;
    }

    $this->_db_builder->order_by($column, $direction);
    }
    }

    if ($multiple === TRUE)
    {
    // Return database iterator casting to this object type
    $result = $this->_db_builder->as_object(get_class($this))->execute($this->_db);

    $this->reset();

    return $result;
    }
    else
    {
    // Load the result as an associative array
    $result = $this->_db_builder->as_assoc()->execute($this->_db);

    $this->reset();

    if ($result->count() === 1)
    {
    // Load object values
    $this->_load_values($result->current());
    }
    else
    {
    // Clear the object, nothing was found
    $this->clear();
    }

    return $this;
    }
    }
    .....

Új hozzászólás Aktív témák

Hirdetés