1

I am using symfony framework for my project, but many time i'm very confused to write mysql query in doctrine mode, so, please suggest me how to write custom query in symfony, like

SELECT * FROM USER WHERE A.ID = 'X3B8882'
tanujdave
  • 237
  • 4
  • 15

2 Answers2

2

Your sql is invalid, but assuming A is a reference to the user table:

$user = Doctrine_Query::create()
  ->from("User a")
  ->where("a.id = ?", "X3B8882")
  ->fetchOne();

or alternatively

$user = UserTable::getInstance()->findOneById("X3B8882");

This is one of the most basic queries, so I highly recommend you read the documentation available on doctrine's homepage.

Maerlyn
  • 33,687
  • 18
  • 94
  • 85
1
$query="SELECT * FROM USER WHERE A.ID = 'X3B8882'"    

$conn = Doctrine_Manager::getInstance()->connection();
    $stmt = $conn->prepare($query);
    $stmt->execute();
    while ($row = $stmt->fetch()) {
        $results[] = $row['sm_mnuitem_webpage_url'] ;

    }
Roshan Wijesena
  • 3,106
  • 8
  • 38
  • 57