Solar_Sql_Model_Params_Fetch alias

View: New views
1 Messages — Rating Filter:   Alert me  

Solar_Sql_Model_Params_Fetch alias

by Jon Elofson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I am trying to add some documentation to this page:
http://solarphp.org/manual:model:fetching_objects. There were several
stubs for the fetch options I thought I might take a stab at filling
in. One of those is 'alias'.
$list = $model->fetchAll(array('alias'=>'foo'));
Works as expected and adjusts the order by statement.
...
FROM `table` `foo`
ORDER BY
    `foo`.`id` ASC

$list = $model->fetch($id, array('alias'=>'foo'));
Doesn't work as the WHERE clause and ORDER BY are preset to use the
original table name. Not sure this is a big deal. Why would you use an
alias here anyway?

Using it with an eager fetch has similar results.

$eager = array(
    'table'=>array('alias'=>'foo')
);

$item = $model->fetchAll(array('eager'=>$eager));

Doesn't work due to the eager table being ordered by the original table name.

Since I don't use this option, I don't know if I am missing the intent
of alias or not. Perhaps it shouldn't even be used in these cases.
If anyone knows the proper use of this option, let me know and I can
add it to the docs.

Jon
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk