Skip to content

Instantly share code, notes, and snippets.

@nomaanp
Last active December 19, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomaanp/750f328669f1b8f91957 to your computer and use it in GitHub Desktop.
Save nomaanp/750f328669f1b8f91957 to your computer and use it in GitHub Desktop.
Table desc
Address Table = 'addr'
States Table = 'states'
City Table = 'city'
Addr_Category Table = 'addr_category'
In Model
$sql1 = new Sql($this->dbAdapter);
$selct = new Select(array('a' => 'addr'));
$selct->join(array('f'=>'states'),'f.id = a.state_id',array('state_name' => 'name'))
->join(array('d'=>'city'),'d.id = a.city_id',array('city_name' => 'name'))
->join(array('e'=>'addr_category'),'e.id = a.cat_id')
->order('a.name');
$selectString = $sql1->getSqlStringForSqlObject($selct);
$result = $this->dbAdapter->query($selectString,DbAdapter::QUERY_MODE_EXECUTE);
In view script
On edit and delete link, it is returning the addr_category's id instead of addr's id
<a href="<?php echo $this->url('address/edit', array('action' => 'edit', 'id' => $address->id));
?>"><img src="../public/img/edit.png" alt="Edit"/></a>
<a href="<?php echo $this->url('address/delete', array('action' => 'delete', 'id' => $address->addrid));
?>"><img src="../public/img/delete.png" alt="Delete"/></a>
@settermjd
Copy link

Hi Mohammad,

In the view script snippet in your Gist, did you intend to have $address->id for edit but $address->addrid for delete? It seems you're referring to two different columns here. Also, can you add a definition of the addr_category table (though shouldn't be specifically necessary)?

Matt

@nomaanp
Copy link
Author

nomaanp commented Jul 8, 2013

Actuallly for delete link it is $address->id and definition for addr_category is id,caname

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment