Re: [PHP-DB] mysqli auto rollback on script termination

2006-10-10 Thread Hodicska Gergely
Reason I'm asking is, I've seen some deadlock issues in a script (using 
FOR UPDATE and LOCK IN SHARE MODE), that looks like they are caused by 
transactions not being rolled back (releasing locks) correctly.

Do you use pconnect? If I right remember there was a bug in some version
of mysql that in the case of using pconnect in some cases the automatic
rollback didn't happen. The solution was: after pconnect one had to
start with a rollback command.


Regards,
Felhő

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] SELECT date query

2006-10-07 Thread Hodicska Gergely

Hi!


You can make this easier with date('w').
 $correction = array(3, 2, 1, 7, 6, 5, 4);
 list($year, $month, $day, $dayOfWeek) = explode('|', date('Y|m|d|w'));
 echo date (Y.m.d, mktime 
(0,0,0,$month,$day+$correction[$dayOfWeek],$year));



Regards,
Felhő


Niel Archer wrote:

Hi Ron

I've made the assumption that if today is Wednesday, you still want next
Wednesday.
Try this:

$offset = array(3,2,1,7,6,5,4);
$date = explode(-, date(Y-n-j));
$ToDay = DayOfWeek($date[0], $date[1], $date[2]);
$NextWed = date(Y-n-j, time() + ($offset[$ToDay] * 24 * 60 * 60));

// Returns a digit in range 0-6. 0 = Sunday, 6 = Saturday
function DayOfWeek($Year, $Month, $Day)
{
$t = array(0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4);
$Year -= $Month  3;
return ($Year + ($Year / 4) - ($Year / 100) + ($Year / 400) +
$t[$Month - 1] + $Day) % 7;
}


Niel



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php