Re: [PHP-DB] Help on query report...

2006-11-16 Thread Chris

Suprie wrote:

dear all,

i have this table

id  | contract No |  site id | handover date |status| finishing date |
contract value|actual value
1 | T0001  | LOS01 | 12-Apr-06| Done | 11-Apr-06 |
12,000  | 12,000
2 | T0002  | LOS02 | 12-Apr-06| Done | 11 Apr-06 |
11,000  | 11,000
3 | T0001  | LOS02 |   | Done | 13-Apr-06
  | 13,000  | 13,000
4 | T0003  | LOS01 |   | Cancel |
   | 11,000  |

now my manager asked me to produce summary report like :

Contract No | TOTAL site | Total Cancelled | Total Active | Handovered
| Contract Value |
T0001 |   2  |  0| 2
|1 |  25,000|
T0002 |  1   |  0| 1
|   1  |  11,000|
T0003 |  1   |  1| 0
|   0  |   11,000   |


is there some way to do it in mySQL? i'm using php 5 and mysql 5.1
right now i'm doing it manually, but i thinks it was really
complex...Could somebody help me with the query ?
many thanks,


Show us the query you already have rather than us just guessing the 
tables etc.


--
Postgresql & php tutorials
http://www.designmagick.com/

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



[PHP-DB] Help on query report...

2006-11-16 Thread Suprie

dear all,

i have this table

id  | contract No |  site id | handover date |status| finishing date |
contract value|actual value
1 | T0001  | LOS01 | 12-Apr-06| Done | 11-Apr-06 |
12,000  | 12,000
2 | T0002  | LOS02 | 12-Apr-06| Done | 11 Apr-06 |
11,000  | 11,000
3 | T0001  | LOS02 |   | Done | 13-Apr-06
  | 13,000  | 13,000
4 | T0003  | LOS01 |   | Cancel |
   | 11,000  |

now my manager asked me to produce summary report like :

Contract No | TOTAL site | Total Cancelled | Total Active | Handovered
| Contract Value |
T0001 |   2  |  0| 2
|1 |  25,000|
T0002 |  1   |  0| 1
|   1  |  11,000|
T0003 |  1   |  1| 0
|   0  |   11,000   |


is there some way to do it in mySQL? i'm using php 5 and mysql 5.1
right now i'm doing it manually, but i thinks it was really
complex...Could somebody help me with the query ?
many thanks,

br


--
Jangan tanyakan apa yang Indonesia telah berikan pada mu
tapi bertanyalah apa yang telah engkau berikan kepada Indonesia

-BEGIN GEEK CODE BLOCK-
Version: 3.1
GU/IT  d- s: a-- C++ UL P L++ E W++ N* o-- K-
w PS  Y-- PGP- t++ 5 X R++ tv  b+ DI D+ G e+ h* r- z?
--END GEEK CODE BLOCK--

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



Re: [PHP-DB] berkeley db + php + locking

2006-11-16 Thread Christopher Jones

Chris,

I've emebedded inline an answer from George Feinberg from the
Sleepycat team.

Chris

Chris Peiffer wrote:

I'm having trouble getting php working with db4 so that it does
correct write-locking in an apache webserver environment (where there
are potentially many applications writing at once.)

The first thing I did:

I compiled the db4 package from sleepycat/oracle and configured it
into php. (Using the --with-db4=/usr/local/BerkeleyDB.4.4 directive to
php's configure.)

With this the php binary is linked to the Berkeley libs, and one can
use those libs through the standard php dba_* API, by opening db
resources with the db4 handler, like this:

$dbres = dba_open($filename, 'wd', 'db4');

This works for accessing, creating and writing files. However, it
doesn't handle write locking properly.

If two procs both call dba_open with a write lock, they both get the
lock. Whover closes the resource first gets its values written to
the file. This is not the correct behavior... you can't have a true
mutex unless one of them blocks on the open when the write lock is
taken up by the other.

I found this page, which (poorly) documents the native php API for
Berkeley db:

http://www.oracle.com/technology/documentation/berkeley-db/db/ref/ext/php.html

From within the db distribution tree I installed their php extension,
db4.so (by running phpize, configure, make, make install within the
php_db4 directory under the db src.)

I can get their samples to run, but the samples don't deal with write
locking at all. The documentation is maddening, because most of it
has to be inferred from the C API documentation. I'm finding it very
hard to get any kind of error reports or logs out of the thing.

This page suggests a scenario that I want: simple multiple reader /
single writer access to a suite of db4 files:

http://www.oracle.com/technology/documentation/berkeley-db/db/ref/cam/intro.html

However, it says "You must specify DB_INIT_CDB and DB_INIT_MPOOL to
DB_ENV->open." When I try to do this in php I get failure where the
standard db->open succeeds. However, I can't figure out why.
Similarly, cursor operations fail.

Does anybody know of any good examples of using db4 and php?


If you want to use DB_INIT_CDB, the syntax for the open call is:
$env->open("path_to_environment", DB_INIT_CDB|DB_INIT_MPOOL|DB_CREATE);


One note on the Berkeley DB PHP API -- it is not a wrapper of the
complete API.  It only implements a subset of the methods for any of
the classes.  If any are missing, and there is no work around, they
can be requested.  The Berkeley DB OTN Forum is the best
place to talk about these issues, as it's monitored by the team.
It's here:
http://forums.oracle.com/forums/forum.jspa?forumID=271

The Db4Env class is particularly sparse, but that is because nearly
all of its configuration can be emulated using a configuration file,
rather than API.  See the documentation on the
DB_CONFIG configuration file here:
http://www.oracle.com/technology/documentation/berkeley-db/db/ref/env/db_config.html


George



Specifically, with locking?

Is there any way to get db_strerror working?

Is there at least a better documented API than the Oracle one? (As an
example of how crappy it is, it omits the "put" method from class Db4
but that method does in fact exist within the library.) 


Thank you for any help you can offer. I have searched the web and the
archives of this list but I couldn't find much.




--
Christopher Jones, Oracle
Email: [EMAIL PROTECTED]Tel: +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

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



Re: [PHP-DB] php5 coding class objects best practices

2006-11-16 Thread Chris

Chris Barnes wrote:

hi people,
i havent used thi slist for quite a while.

anyway. Im trying to write an application which relies heavily on mysql. so
i have made a class object which has all the functions to make using mysql
very easy for me.

but the problem im faced with now is, i have a bunch of other classes, 
which

have a dependency to be able to read or write to mysql at some point.

i dont want to have to write and maintain seperate mysql classes to extend
other other classes.

is it alright to, for example, point to one class from within another?

e.g.

$user = new User();

$user->mysql = new MySql();

and then call functions in MySql() from within User() by;

$this->mysql->fetch_result_into_array();

im new to PHP5 so im not aware of all its new and awesome OO features.


Yes, that will work fine.

It also works in php4, it's not a php5 specific feature.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP-DB] Special Character

2006-11-16 Thread Kevin Murphy
A solution I use is to do apply this function to all POST data  
collected. The key here for your problem is the chr(150) and chr(151)  
that are replaced with a normal hyphen. This also takes care of MS  
Words Smart Quotes. If there are other MS Characters you need to  
convert, just add them to the pattern field as the numeric version,  
and then add one to the array what the replacement is.


function sanitize($data)
{
  	$pattern = array(chr(145),chr(146),chr(147),chr(148),chr(150),chr 
(151));

$replacements = array("'","'",'"','"','-','--');
$data = str_replace($pattern,$replacements,$data);
$data = trim($data);
$data = preg_replace("/ +/", " ", $data);
$data = addslashes($data);
return $data;
}



--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


On Nov 16, 2006, at 7:32 AM, David Skyers wrote:


Thanks,

The problem is, we will have hundreds of users using Microsoft Word  
and

we cannot switch it off for all of them. Ideally I need some type of
string replace function, so no matter what they enter it gets  
trapped an

replaced.

It's not the normal hyphens that cause a problem but the long hyphens.

Regards

David

-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED]
Sent: 16 November 2006 15:13
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Special Character

To turn off the auto formatting of hyphens:

In Microsoft Word 2003:

Open a new document.
Go to Tools>Auto Correct Options>
Select the "Auto Format As You Type" tab Deselect the "Hyphens (--)  
with

Dash (-)" option.

Even though it says it will replace a double hyphen (--) with a Dash
(This is an em dash) it also does the same thing for a single hyphen
depending on the sentance structure.

Hope this helps!

Dan


On 11/16/06, Niel Archer <[EMAIL PROTECTED]> wrote:


Hi David

What you describe sounds like Word is auto replacing hyphens with
either
en- or em-dashes.  This is a configurable option in Word that often
defaults to on.  Try using double quotes, If they get switched to  
66's

and 99's style quotes, then that is likely the problem.  I no longer
use MS Office for these and other reasons, so cannot tell you how to
switch off this formatting.  But it can be switched off, somewhere

within it.


The only other option I can think of would be to change your Db
character set to one that can accept these extended characters. That
might also mean changing some of Window's/Word's behaviour (to be
using
UTF-8 for example).

Niel

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

http://www.php.net/unsub.php









Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi

Doh... that's 'mbstring'

Niel

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



Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi David

off the top of my head, the best I can suggest is using PHP's MB
functions (lookup mb_string) to allow recognition and then convert them
to hyphens.

Niel

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



RE: [PHP-DB] Special Character

2006-11-16 Thread David Skyers
Thanks,

The problem is, we will have hundreds of users using Microsoft Word and
we cannot switch it off for all of them. Ideally I need some type of
string replace function, so no matter what they enter it gets trapped an
replaced.

It's not the normal hyphens that cause a problem but the long hyphens.

Regards

David

-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED]
Sent: 16 November 2006 15:13
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Special Character

To turn off the auto formatting of hyphens:

In Microsoft Word 2003:

Open a new document.
Go to Tools>Auto Correct Options>
Select the "Auto Format As You Type" tab Deselect the "Hyphens (--) with
Dash (-)" option.

Even though it says it will replace a double hyphen (--) with a Dash
(This is an em dash) it also does the same thing for a single hyphen
depending on the sentance structure.

Hope this helps!

Dan


On 11/16/06, Niel Archer <[EMAIL PROTECTED]> wrote:
>
> Hi David
>
> What you describe sounds like Word is auto replacing hyphens with
> either
> en- or em-dashes.  This is a configurable option in Word that often
> defaults to on.  Try using double quotes, If they get switched to 66's
> and 99's style quotes, then that is likely the problem.  I no longer
> use MS Office for these and other reasons, so cannot tell you how to
> switch off this formatting.  But it can be switched off, somewhere
within it.
>
> The only other option I can think of would be to change your Db
> character set to one that can accept these extended characters. That
> might also mean changing some of Window's/Word's behaviour (to be
> using
> UTF-8 for example).
>
> Niel
>
> --
> PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>




Re: [PHP-DB] Special Character

2006-11-16 Thread Dan Shirah

To turn off the auto formatting of hyphens:

In Microsoft Word 2003:

Open a new document.
Go to Tools>Auto Correct Options>
Select the "Auto Format As You Type" tab
Deselect the "Hyphens (--) with Dash (-)" option.

Even though it says it will replace a double hyphen (--) with a Dash (This
is an em dash) it also does the same thing for a single hyphen depending on
the sentance structure.

Hope this helps!

Dan


On 11/16/06, Niel Archer <[EMAIL PROTECTED]> wrote:


Hi David

What you describe sounds like Word is auto replacing hyphens with either
en- or em-dashes.  This is a configurable option in Word that often
defaults to on.  Try using double quotes, If they get switched to 66's
and 99's style quotes, then that is likely the problem.  I no longer use
MS Office for these and other reasons, so cannot tell you how to switch
off this formatting.  But it can be switched off, somewhere within it.

The only other option I can think of would be to change your Db
character set to one that can accept these extended characters. That
might also mean changing some of Window's/Word's behaviour (to be using
UTF-8 for example).

Niel

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




Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi David

What you describe sounds like Word is auto replacing hyphens with either
en- or em-dashes.  This is a configurable option in Word that often
defaults to on.  Try using double quotes, If they get switched to 66's
and 99's style quotes, then that is likely the problem.  I no longer use
MS Office for these and other reasons, so cannot tell you how to switch
off this formatting.  But it can be switched off, somewhere within it. 

The only other option I can think of would be to change your Db
character set to one that can accept these extended characters. That
might also mean changing some of Window's/Word's behaviour (to be using
UTF-8 for example).

Niel

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



RE: [PHP-DB] Special Character

2006-11-16 Thread David Skyers
Hi Niel

That's the problem I don't know what it is, but I do know that I press
the hyphen/minus key on my keyborad. If I type in 'The -' then press
enter and copy and paste this from word, it then gets displayed as
question mark in Oracle.

David

 

-Original Message-
From: Niel Archer [mailto:Niel Archer] On Behalf Of Niel Archer
Sent: 16 November 2006 13:26
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Special Character

Hi

Is it really a hyphen, or is it an en- or em-dash.  The latter two could
mess up in in some character sets.

Niel

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

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



Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi

Is it really a hyphen, or is it an en- or em-dash.  The latter two could
mess up in in some character sets.

Niel

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



[PHP-DB] Special Character

2006-11-16 Thread David Skyers
Hi ,

We have a problem with storing data into our oracle database that is
copied from Microsoft word. A typical example would be a hyphen, if
entered directly in an input box this is stored fine. However if copied
from Microsoft word it is displayed as a question mark.

Has anyone else experienced this and are there any resolutions?

Thanks

David 



[PHP-DB] php5 coding class objects best practices

2006-11-16 Thread Chris Barnes

hi people,
i havent used thi slist for quite a while.

anyway. Im trying to write an application which relies heavily on mysql. so
i have made a class object which has all the functions to make using mysql
very easy for me.

but the problem im faced with now is, i have a bunch of other classes, which
have a dependency to be able to read or write to mysql at some point.

i dont want to have to write and maintain seperate mysql classes to extend
other other classes.

is it alright to, for example, point to one class from within another?

e.g.

$user = new User();

$user->mysql = new MySql();

and then call functions in MySql() from within User() by;

$this->mysql->fetch_result_into_array();

im new to PHP5 so im not aware of all its new and awesome OO features.

does anyone have any advise?