[Solar-talk] role/adapter/sql

Jeff Surgeson solar at 3hex.com
Mon Dec 4 13:34:22 PST 2006


Hi All

I see that the latest Solar_Role_Adapter_Sql fetch method has changed somewhat 
but appears broken, at least for me anyway, If I replace it with the old 
version of of the code all works ok works ok.

Looking at the errors and warnings, $obj should probably be $sql but $stmt and 
$data are no longer defined due to the changes.

Am I missing something here or is this method a bit "duer mekaar" :-)

    /**
     *
     * Fetches the roles for a user.
     *
     * @param string $handle User handle to get roles for.
     *
     * @return array An array of roles discovered in the table.
     *
     */
    public function fetch($handle)
    {
        // get the dependency object of class Solar_Sql
        $sql = Solar::dependency('Solar_Sql', $this->_config['sql']);

        // get a selection tool using the dependency object
        $select = Solar::factory(
            'Solar_Sql_Select',
            array('sql' => $sql)
        );

        // build the select
        $select->from($this->_config['table'], $this->_config['role_col'])
               ->where("{$this->_config['handle_col']} = ?", $handle)
               ->multiWhere($this->_config['where']);

        // get the results (a column of rows)
        $result = $obj->select('col', $stmt, $data);

        // done!
        return $result;
    }

       /*/ OLD METHOD get the dependency object of class Solar_Sql
        $obj = Solar::dependency('Solar_Sql', $this->_config['sql']);

        // build the SQL statement
        $stmt =  "SELECT " . $this->_config['role_col']
              .  " FROM " . $this->_config['table']
              .  " WHERE " . $this->_config['handle_col']
              .  " = :handle";

        // build the placeholder data
        $data = array(
            'handle' => $handle,
        );

        // get the results (a column of rows)
        $result = $obj->select('col', $stmt, $data);

        // done!
        return $result;

-- 
Jeff Surgeson / South Africa


More information about the solar-talk mailing list