Reputation: 237
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'
Upvotes: 1
Views: 2122
Reputation: 3136
$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'] ;
}
Upvotes: 1
Reputation: 34107
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.
Upvotes: 2