I have used the below code. Please suggest me if I am wrong.
<?php
class Fooman_Example_Model_Observer
{
public function AddProductSaveBefore($observer)
{
$quote = Mage::getSingleton('checkout/session')->getQuote();
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$customerId = $customerData->getId();
$time = time();
$toDate = date('Y-m-d H:i:s', $time);
$lastTime = $time - 100000000;
$fromDate = date('Y-m-d H:i:s', $lastTime);
$order = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('customer_id', $customerId)
->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))
->addFieldToFilter('sku', array('in' => Mage::getSingleton('catalog/product')->getSku()))
->load();
}
if ((count($order->getItems()) - 1) >= 1) {
Mage::throwException('You already ordered today');
}
}
}