php-general Digest 17 Sep 2011 21:47:22 -0000 Issue 7483
php-general Digest 17 Sep 2011 21:47:22 - Issue 7483 Topics (messages 314919 through 314924): mysql adapter and DAL 314919 by: shahrzad khorrami 314920 by: jean-baptiste verrey 314922 by: Nilesh Govindarajan Re: Round with money_format 314921 by: Bill Guion 314923 by: Tedd Sperling 314924 by: Richard Quadling Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- hi all, I'm looking for a mysql adapter for create my dal.. where can I find a good one? and have you ever written a dal with a mysql adapter? in my dal I want to pass parameters to sql sting, for example like following: $db-query($sql, array($name, $family)) thanks, Shahrzad Khorrami ---End Message--- ---BeginMessage--- hi, If you are building your own dal I guess you would have to build your own adapter, simply use mysqli function and wrap them in a class. On 17 September 2011 12:24, shahrzad khorrami shahrzad.khorr...@gmail.comwrote: hi all, I'm looking for a mysql adapter for create my dal.. where can I find a good one? and have you ever written a dal with a mysql adapter? in my dal I want to pass parameters to sql sting, for example like following: $db-query($sql, array($name, $family)) thanks, Shahrzad Khorrami ---End Message--- ---BeginMessage--- Sorry, I clicked the 'reply' button instead of reply to all. Original Message Subject: Re: [PHP] mysql adapter and DAL Date: Sat, 17 Sep 2011 19:07:48 +0530 From: Nilesh Govindarajan cont...@nileshgr.com To: shahrzad khorrami shahrzad.khorr...@gmail.com On Sat 17 Sep 2011 04:54:13 PM IST, shahrzad khorrami wrote: hi all, I'm looking for a mysql adapter for create my dal.. where can I find a good one? and have you ever written a dal with a mysql adapter? in my dal I want to pass parameters to sql sting, for example like following: $db-query($sql, array($name, $family)) thanks, Shahrzad Khorrami Why do you want to reinvent the wheel? There are many Database Abstraction Layer packages which support MySQL. Pear::MDB2, Zend_Db, CodeIgniter, ... the list doesn't end. Search for them! -- Nilesh Govindarajan http://nileshgr.com -- Nilesh Govindarajan http://nileshgr.com ---End Message--- ---BeginMessage--- On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: From: Cyril Lopez cy...@nethik.fr Date: September 16, 2011 10:58:28 AM EDT To: php-gene...@lists.php.net Subject: Round with money_format Hi, Can someone help me understand how money_format() rounds numbers ? ?php setlocale(LC_ALL, 'fr_FR.UTF-8'); $price = 12.665; echo money_format('%i',$price); // 12.66 EUR, 12.67 EUR expected $price2 = 12.666; echo money_format('%i',$price2); // 12.67 EUR, ok echo round($price,2); // 12.67, ok echo round($price2,2); // 12.67, ok ? Misconfiguration ? Bug ? Thanks ! Cyril Config : Debian Lenny, PHP 5.3.8 As someone else pointed out, rounding rules vary by locale, but I was taught 40+ years ago in graduate school programming class, 4 rounds down, 6 rounds up, and 5 rounds to the even number. This means 65 rounds to 6, while 75 rounds to 8. Your example seems to follow that rule. -= Bill =- -- Virtuous action will never go unpunished. ---End Message--- ---BeginMessage--- On Sep 17, 2011, at 10:56 AM, Bill Guion wrote: On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: Can someone help me understand how money_format() rounds numbers ? As someone else pointed out, rounding rules vary by locale, but I was taught 40+ years ago in graduate school programming class, 4 rounds down, 6 rounds up, and 5 rounds to the even number. This means 65 rounds to 6, while 75 rounds to 8. Your example seems to follow that rule. Bill: For many years (40+) I've claimed the same solution. I even wrote a routine to prove that algorithm is better than the one used in round(). The only problem is that it requires millions of instances to show any significant difference. IOW, it's simply not worth the effort. Cheers, tedd _ t...@sperling.com http://sperling.com ---End Message--- ---BeginMessage--- On 17 September 2011 15:56, Bill Guion bgu...@comcast.net wrote: On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: From: Cyril Lopez cy...@nethik.fr Date: September 16, 2011 10:58:28 AM EDT To: php-gene...@lists.php.net Subject: Round with money_format Hi, Can someone help me understand how money_format() rounds numbers ? ?php setlocale(LC_ALL, 'fr_FR.UTF-8'); $price = 12.665; echo money_format('%i',$price); // 12.66 EUR, 12.67 EUR expected $price2 = 12.666; echo money_format('%i',$price2); // 12.67 EUR, ok echo round($price,2);
Fwd: [PHP] Help on number matching function
Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or if you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any). Not another one... Sending e-mail to a public mailing list MUST be intended for the public. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql adapter and DAL
hi all, I'm looking for a mysql adapter for create my dal.. where can I find a good one? and have you ever written a dal with a mysql adapter? in my dal I want to pass parameters to sql sting, for example like following: $db-query($sql, array($name, $family)) thanks, Shahrzad Khorrami
Re: [PHP] mysql adapter and DAL
hi, If you are building your own dal I guess you would have to build your own adapter, simply use mysqli function and wrap them in a class. On 17 September 2011 12:24, shahrzad khorrami shahrzad.khorr...@gmail.comwrote: hi all, I'm looking for a mysql adapter for create my dal.. where can I find a good one? and have you ever written a dal with a mysql adapter? in my dal I want to pass parameters to sql sting, for example like following: $db-query($sql, array($name, $family)) thanks, Shahrzad Khorrami
Re: Re: [PHP] Round with money_format
On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: From: Cyril Lopez cy...@nethik.fr Date: September 16, 2011 10:58:28 AM EDT To: php-general@lists.php.net Subject: Round with money_format Hi, Can someone help me understand how money_format() rounds numbers ? ?php setlocale(LC_ALL, 'fr_FR.UTF-8'); $price = 12.665; echo money_format('%i',$price); // 12.66 EUR, 12.67 EUR expected $price2 = 12.666; echo money_format('%i',$price2); // 12.67 EUR, ok echo round($price,2); // 12.67, ok echo round($price2,2); // 12.67, ok ? Misconfiguration ? Bug ? Thanks ! Cyril Config : Debian Lenny, PHP 5.3.8 As someone else pointed out, rounding rules vary by locale, but I was taught 40+ years ago in graduate school programming class, 4 rounds down, 6 rounds up, and 5 rounds to the even number. This means 65 rounds to 6, while 75 rounds to 8. Your example seems to follow that rule. -= Bill =- -- Virtuous action will never go unpunished. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: Re: [PHP] mysql adapter and DAL
Sorry, I clicked the 'reply' button instead of reply to all. Original Message Subject: Re: [PHP] mysql adapter and DAL Date: Sat, 17 Sep 2011 19:07:48 +0530 From: Nilesh Govindarajan cont...@nileshgr.com To: shahrzad khorrami shahrzad.khorr...@gmail.com On Sat 17 Sep 2011 04:54:13 PM IST, shahrzad khorrami wrote: hi all, I'm looking for a mysql adapter for create my dal.. where can I find a good one? and have you ever written a dal with a mysql adapter? in my dal I want to pass parameters to sql sting, for example like following: $db-query($sql, array($name, $family)) thanks, Shahrzad Khorrami Why do you want to reinvent the wheel? There are many Database Abstraction Layer packages which support MySQL. Pear::MDB2, Zend_Db, CodeIgniter, ... the list doesn't end. Search for them! -- Nilesh Govindarajan http://nileshgr.com -- Nilesh Govindarajan http://nileshgr.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Round with money_format
On Sep 17, 2011, at 10:56 AM, Bill Guion wrote: On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: Can someone help me understand how money_format() rounds numbers ? As someone else pointed out, rounding rules vary by locale, but I was taught 40+ years ago in graduate school programming class, 4 rounds down, 6 rounds up, and 5 rounds to the even number. This means 65 rounds to 6, while 75 rounds to 8. Your example seems to follow that rule. Bill: For many years (40+) I've claimed the same solution. I even wrote a routine to prove that algorithm is better than the one used in round(). The only problem is that it requires millions of instances to show any significant difference. IOW, it's simply not worth the effort. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Round with money_format
On 17 September 2011 15:56, Bill Guion bgu...@comcast.net wrote: On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: From: Cyril Lopez cy...@nethik.fr Date: September 16, 2011 10:58:28 AM EDT To: php-general@lists.php.net Subject: Round with money_format Hi, Can someone help me understand how money_format() rounds numbers ? ?php setlocale(LC_ALL, 'fr_FR.UTF-8'); $price = 12.665; echo money_format('%i',$price); // 12.66 EUR, 12.67 EUR expected $price2 = 12.666; echo money_format('%i',$price2); // 12.67 EUR, ok echo round($price,2); // 12.67, ok echo round($price2,2); // 12.67, ok ? Misconfiguration ? Bug ? Thanks ! Cyril Config : Debian Lenny, PHP 5.3.8 As someone else pointed out, rounding rules vary by locale, but I was taught 40+ years ago in graduate school programming class, 4 rounds down, 6 rounds up, and 5 rounds to the even number. This means 65 rounds to 6, while 75 rounds to 8. Your example seems to follow that rule. I've been looking to see if I can find the locale's rounding rules - I can't. Would be useful if anyone knows where they are defined. As far as I can find (pages similar to http://www.cl.cam.ac.uk/cgi-bin/manpage?7+locale), the locale data doesn't seem to include the rounding rules. Sure, the number of DP, grouping, etc. Yes. But no rounding. So, does this just truncate? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] mysql adapter and DAL
mysqli - it's what I wanted. thanks