<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Latest snippets tagged propel</title>
  <link rel="alternate" href="http://snippets.prendreuncafe.com/snippets/tagged/propel/order_by/date"></link>
  <id>http://snippets.prendreuncafe.com/snippets/tagged/propel/order_by/date</id>
  <updated>2008-03-30T15:34:49Z</updated>
  <author>
    <name>Symfony</name>
    <author_email>noreply@symfony-project.com</author_email>
  </author>
<entry>
  <title>Symfony, trier aléatoirement les résultat avec Propel et MySQL</title>
  <link href="http://snippets.prendreuncafe.com/snippet/83"></link>
  <updated>2008-03-30T15:34:49Z</updated>
  <id>83</id>
  <summary type="html">Attention, cela ne fonctionnera probablement qu'avec MySQL :

[code php]
&lt;?php
$c = new criteria;
$c-&gt;addAscendingOrderByColumn('rand()');
$results = TotoPeer::doSelect($c);
[/code]</summary>
</entry>
<entry>
  <title>[Symfony 1.1 beta] Créer un test unitaire et initialiser Propel</title>
  <link href="http://snippets.prendreuncafe.com/snippet/79"></link>
  <updated>2008-03-19T17:27:18Z</updated>
  <id>79</id>
  <summary type="html">Depuis l'apparition du nouveau système de configuration de Symfony 1.1, voici un boostrap type pour vos tests unitaires nécessitant l'accès à l'environnement Propel :

[code php]
&lt;?php
require_once(dirname(__FILE__).'/../../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('main', 'test', true);
include($configuration-&gt;getSymfonyLibDir().'/vendor/lime/lime.php');
sfContext::createInstance($configuration);
[/code]

Pensez cependant à remplacer `main` par le nom de votre application courante (par ex. `frontend`).</summary>
</entry>
<entry>
  <title>[Symfony] [Propel] Afficher la dernière requête effectuée</title>
  <link href="http://snippets.prendreuncafe.com/snippet/72"></link>
  <updated>2007-12-10T15:56:12Z</updated>
  <id>72</id>
  <summary type="html">Pour afficher la dernière requête effectuée avec Propel :

[code=php]
echo Propel::getConnection()-&gt;getLastExecutedQuery();
[/code]

C'est tout con, hein ?</summary>
</entry>
<entry>
  <title>Gérer les libellés et tris d'un selectbox avec Propel et les helpers objets Symfony</title>
  <link href="http://snippets.prendreuncafe.com/snippet/71"></link>
  <updated>2007-11-21T16:40:15Z</updated>
  <id>71</id>
  <summary type="html">Pour gérer un joli combobox avec des valeurs textuelles représentatives choisies pour un objet Propel et éventuellement les trier, on peut faire :

[code=php]
&lt;?php echo object_select_tag($produit, 'getTypeProduitId', array (
 'related_class' =&gt; 'TypeProduit',   
 'peer_method'   =&gt; 'doSelectOrderByCode',
)) ?&gt;
[/code]

ou bien dans un generator.yml

[code=php]
fields:
  departement_id: 
    params: text_method=getNomCode  peer_method=doSelectOrderByCode
[/code]</summary>
</entry>
<entry>
  <title>[Symfony] Cacher un objet Propel sérialisé</title>
  <link href="http://snippets.prendreuncafe.com/snippet/43"></link>
  <updated>2007-01-17T10:26:22Z</updated>
  <id>43</id>
  <summary type="html">Peut être utile pour les gros objets couteux et utilisés souvent.

[code]
$key = md5('myPropelObjectKey');
$cache = new sfProcessCache();
if ($cache-&gt;has($key)) 
{
  $obj = unserialize($cache-&gt;get($key));
}
else
{
  $obj = Table::doSelect();
  $cache-&gt;set($key, serialize($obj))
}
[/code]</summary>
</entry>
<entry>
  <title>[Symfony] Traiter les OR sql avec Propel</title>
  <link href="http://snippets.prendreuncafe.com/snippet/40"></link>
  <updated>2007-01-15T12:05:04Z</updated>
  <id>40</id>
  <summary type="html">Voici comment gérer les &quot;ou&quot; SQL dans Propel :

[code]
$criteria = new Criteria();
$criteria-&gt;add(TotoPeer::NAME, 'Gérard Bouchard');
$criterion = $criteria-&gt;getNewCriterion (
  TotoPeer::ID, 5
)-&gt;addOr($criteria-&gt;getNewCriterion (
  TotoPeer::ID, 10
));
$criteria-&gt;addAnd($criterion);
TotoPeer::doSelect($criteria);
[/code]

Ceci donnera quelque chose comme :

[code]
SELECT 
  * 
FROM 
  toto 
WHERE 
  toto.NAME = 'Gérard Bouchard' 
  AND 
  (
    toto.ID = 5 
    OR 
    toto.ID = 10
  );
[/code]</summary>
</entry>
<entry>
  <title>[Symfony] Executer une requête spécifique (custom query) avec Propel</title>
  <link href="http://snippets.prendreuncafe.com/snippet/22"></link>
  <updated>2006-11-28T10:10:13Z</updated>
  <id>22</id>
  <summary type="html">[code]
$con = Propel::getConnection();
$stmt = $con-&gt;prepareStatement('SELECT foo, bar FROM baz WHERE name=? AND active=?');
$stmt-&gt;setString(1, 'MyName');
$stmt-&gt;setString(2, '1');
$rs = $stmt-&gt;executeQuery(ResultSet::FETCHMODE_NUM);
[/code]

Ou encore plus con :

[code]
Propel::getConnection()-&gt;executeUpdate('SET FOREIGN_KEY_CHECKS=0');
[/code]</summary>
</entry>
</feed>