Stephen's dev blog

Custom SQL in symfony 1.2.3

Posted by: Stephen Gray on: 29 June, 2009

Quick one. A small snippet for performing custom SQL queries using symfony 1.2.3. The method to do this has varied slightly with the different symfony releases. The method found on the symfony site almost has a good example, this is just adding a bit to it (looping);

    $conn = Propel::getConnection();
    $query = 'SELECT * FROM `my_table`;';

    $statement = $conn->prepare($query);
    $statement->execute();

    while ($rowObj = $statement->fetch(PDO::FETCH_OBJ))
    {
        echo var_dump($rowObj);
    }

Stephen.

Leave a Reply