Skip to content

Instantly share code, notes, and snippets.

@oelmekki
Created August 30, 2010 14:40
Show Gist options
  • Save oelmekki/557502 to your computer and use it in GitHub Desktop.
Save oelmekki/557502 to your computer and use it in GitHub Desktop.
<?php
// sans :
// tous les produits
$records = $this->Database->execute( 'select * from tl_products where published = 1' );
$products = array();
while ( $records->next() )
{
$products[] = $records->row();
}
// produit 1
$record = $this->Database->execute( 'select * from tl_products where id = 1' );
$record->next();
$product = $record->row();
if ( $post = $this->Input->post( 'product' ) )
{
$this->Database->prepare( 'update tl_products ? where id = 1' )->set( $post )->execute();
}
$this->Template->products = $products;
$this->Template->product = $product;
// avec :
$product = new Product(1);
$products = $product->getAll( 'id', array( 'published = 1' ) );
if ( $post = $this->Input->post( 'product' ) )
{
$product->update_attributes( $post );
}
$this->Template->products = $products;
$this->Template->product = $product;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment