Tuesday, March 6, 2018

MySQL: SELECT * FROM `table_name` WHERE start and end date within two dates

My query should include the following:
  1. Everything that starts between 2018-03-04 and 2018-03-10
  2. Everything that is due between 2018-03-04 and 2018-03-10
  3. Everything that the period of start_task and due_date falls within 2018-03-04 and 2018-03-10
Answer:

      So you are just missing anything where the start - due task date period spans the week you are checking? You should try this:
SELECT 
    * 
FROM 
    `tasks` tasks 
WHERE 
    (
        (`start_task` >= '2018-03-05 00:00:00' and `start_task` <= '2018-03-11 23:59:59') 
        OR (`due_date` >= '2018-03-05 00:00:00' and `due_date` <= '2018-03-11 23:59:59')
        OR (`start_task` <= '2018-03-11 23:59:59' and `due_date` >= '2018-03-05 00:00:00')
    )

Friday, April 29, 2016

Replace multiple values from string using arrays in PHP

- You can pass multiple values in array as parameters to the str_replace function.


// Result: I love to develop static websites using HTML and CSS

$string  = "I love to develop dynamic websites using PHP and Mysql";        
$string_words = array("dynamic", "PHP", "Mysql");
$new_string_words   = array("static", "HTML", "CSS");
echo $new_string = str_replace($string_words, $new_string_words, $string);

Wednesday, January 6, 2016

Magento - How to find and check username logged in magento admin with username

- To get Admin users collection or all admin users details in magento,


$user_collect = Mage::getModel('admin/user')->getCollection();



- To get users admin role in magento,

$get_user_admin = Mage::getSingleton('admin/session')->getUser();
$
get_user_admin ->getRole()->getData('role_id');


- How to find and check username logged in magento admin,


Mage::getSingleton('core/session', array('name'=>'adminhtml'));
if(  Mage::getSingleton('admin/session')->isLoggedIn() )
{
    $get_user_admin = Mage::getSingleton('admin/session')->getUser();
    echo $current_user_admin = $get_user_admin->getData('username');

// It prints 'saurabh.bansal' if username of magento is 'saurabh.bansal'







MySQL: SELECT * FROM `table_name` WHERE start and end date within two dates

My query should include the following: Everything that starts between 2018-03-04 and 2018-03-10 Everything that is due between 2018-03-0...