[PHP-DB] Where does the mysqli extension find the default connection charset?

2007-05-02 Thread Jean-Noël Rivasseau

Hello there,

I'd like to know which configuration file or setting is used by PHP mysqli
extension to know the default charset connection to the database.

I have two boxes with MySQL 5 / PHP 5 on them. One is a Gentoo box, and on
this one by default the connection happens in UTF-8.  The other server is a
Mac OS X box and it uses latin-1 by default (forcing me to switch manually).

I thought the information would be in /etc/my.cnf (in the client charset
line), but this file is on OS X and it does not work. The only thing I could
see that PHP is using is some locale settings, because on Gentoo locale
prints

LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

whereas on OS X locale prints:

LANG=
LC_COLLATE=C
LC_CTYPE=C
LC_MESSAGES=C
LC_MONETARY=C
LC_NUMERIC=C
LC_TIME=C
LC_ALL=C

So could anyone experienced in the mysqli extension can help me so that I
can set the default charset for the connection to be utf-8 on my OS X box?

Thanks

Jean-Noël


Re: [PHP-DB] Where does the mysqli extension find the default connection charset?

2007-05-02 Thread Georg Richter
Jean-Noël Rivasseau wrote:
 Hello there,
 
 I'd like to know which configuration file or setting is used by PHP mysqli
 extension to know the default charset connection to the database.

mysqli (and also mysql) extension uses the default character set for
libmysql  This can be package dependend: Several distros deliver utf8 as
default, others latin1.

To be on the safe side, you should call mysqli_set_charset($link,
utf8/latin1/whatever) to set the character set for each connection.

/Georg
-- 
Georg Richter, Development Manager - Connectors  Client Connectivity
MySQL GmbH, Radlkoferstr. 2, D-81373 München, www.mysql.com
Geschäftsführer: Hans von Bell, Kaj Arnö - HRB München 162140

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



Re: [PHP-DB] PHP and MYSQL

2007-05-02 Thread James Gadrow

Chris wrote:

Na Derro Cartwright wrote:
I am currently running php4 with mysql 5.  when I try to run a query 
using the mysql command I recieve and error that reads the resource 
id and a number.  What does that mean?


Firstly always cc the list - others will be able to provide their 
input and others will also learn from the problem/resolution.


What is the query? What is the error?

If you run it manually through command line mysql or phpmyadmin do you 
get an error?



You're probably doing something like:

//Open connection and database
$handle = mysql_connect($host, $user, $pass);
mysql_select_db($database);
//Run query
$result = mysql_query(SELECT foo FROM bar);
//Close connection
mysql_close($handle);
//Show result
echo $result;

The correct way to do this is:
//Open connection and database
$handle = mysql_connect($host, $user, $pass);
mysql_select_db($database);
//Run query
$result = mysql_query(SELECT foo FROM bar);
//use resource id returned from query to fetch actual results (note that 
the 0 is a line number so in the case you have more than 1 result you'll 
have to use a different method such as mysql_fetch_assoc or something 
I'd advise you take a look at the documentation @ php.net)

$result = mysql_result($result, 0);
//Close connection
mysql_close($handle);
//Show result
echo $result;

--
Thanks,

Jim

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



[PHP-DB] DB Design Concepts

2007-05-02 Thread Max Thayer
I'm using MySQL 5.x InnoDB engine, transactional tables.  I have a
conceptual design question.  If I have a two columns 'a' and 'b', a is
the primary key, and b is a type double, in table 1 (T1) for which
column b will have many NULL values, do I leave it with an allow null
constraint on the column or pull the column and place it into table 2
(T2) with a foreign key, making a simple optional one-to-one
relationship.  Over the course of time, as the table fills with records,
will a column w/ many NULL values have a detrimental effect on
performance or maintenance with regards to the DB?  Am I missing
something here in DB design 101, by leaving the column in the T1 and
knowing it will only be populated 7% of the time; what are the major
implications based on the RDBMS and engine I'm using?

 

Do I go to 2nd NF simply because a column is not going to be populated
as often?

 

Max H. Thayer

Lead Software Developer

Center for High-Throughput Structural Biology

 

Hauptman-Woodward Medical Research Inst.

700 Ellicott St.

Buffalo, NY 14203

Phone: 716-898-8637

Fax: 716-898-8660

http://www.chtsb.org http://www.chtsb.org/ 

http://www.hwi.buffalo.edu http://www.hwi.buffalo.edu/ 

 



[PHP-DB] Re: [css-d] IE5.5 and td[scope]

2007-05-02 Thread James Gadrow

D. D. Brierton wrote:

On Wed, 2007-05-02 at 16:24 +0100, Martin Paton wrote:

  
I'm using ... 

 #contactform table td[scope] {width:50%} 


... to set the width of the label column of a form. Does IE 5.5 support
this because I can't get it to pick up (or is there a workaround?)



No, IE5.x doesn't support attribute selectors. I don't believe IE6 does
either. Not sure about IE7. The workaround is to give the td elements in
question a class.

  
Supposedly IE7 does support attribute selectors (as well as many other 
advanced selectors) but I've stuck to the older styles for now until the 
other versions of IE drop out of mainstream usage.


--
Thanks,

Jim



RE: [PHP-DB] DB Design Concepts

2007-05-02 Thread Max Thayer
That's one of the kickers.  The 7% of the time the column is populated
is determined by business logic.  And when the business logic says it's
needed, at application run time if certain conditions were met, the
column takes on the characteristic NOT NULL attribute.


-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 02, 2007 3:50 PM
To: Max Thayer
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] DB Design Concepts

Max,
 
I am assuming that since column b will only be populated 7% of the time
that it is not a value specific column (does not matter if it has a
value or not)
 
Therefore I would suggest leaving the NULL's in there as it will not (at
least should not) affect any system performance.

 
On 5/2/07, Max Thayer [EMAIL PROTECTED] wrote: 

I'm using MySQL 5.x InnoDB engine, transactional tables.  I have
a
conceptual design question.  If I have a two columns 'a' and
'b', a is 
the primary key, and b is a type double, in table 1 (T1) for
which
column b will have many NULL values, do I leave it with an allow
null
constraint on the column or pull the column and place it into
table 2
(T2) with a foreign key, making a simple optional one-to-one 
relationship.  Over the course of time, as the table fills with
records,
will a column w/ many NULL values have a detrimental effect on
performance or maintenance with regards to the DB?  Am I missing
something here in DB design 101, by leaving the column in the T1
and 
knowing it will only be populated 7% of the time; what are the
major
implications based on the RDBMS and engine I'm using?



Do I go to 2nd NF simply because a column is not going to be
populated
as often?



Max H. Thayer

Lead Software Developer

Center for High-Throughput Structural Biology



Hauptman-Woodward Medical Research Inst.

700 Ellicott St.

Buffalo, NY 14203 

Phone: 716-898-8637

Fax: 716-898-8660

http://www.chtsb.org http://www.chtsb.org/

http://www.hwi.buffalo.edu http://www.hwi.buffalo.edu
http://www.hwi.buffalo.edu/





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



Re: [PHP-DB] DB Design Concepts

2007-05-02 Thread Dan Shirah

Okay, so couldn't you just set a default value for the column (N for NULL).
This way column 1 and column 2 both contain valid data for whichever state
your column takes on.

Then just tell your logic to omit the results of column 2 that have a value
of N. This way only your valid rows would be pulled and your value for N
would serve the purpose of a NULL as your logic changes the state.


On 5/2/07, Max Thayer [EMAIL PROTECTED] wrote:


That's one of the kickers.  The 7% of the time the column is populated
is determined by business logic.  And when the business logic says it's
needed, at application run time if certain conditions were met, the
column takes on the characteristic NOT NULL attribute.


-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 02, 2007 3:50 PM
To: Max Thayer
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] DB Design Concepts

Max,

I am assuming that since column b will only be populated 7% of the time
that it is not a value specific column (does not matter if it has a
value or not)

Therefore I would suggest leaving the NULL's in there as it will not (at
least should not) affect any system performance.


On 5/2/07, Max Thayer [EMAIL PROTECTED] wrote:

   I'm using MySQL 5.x InnoDB engine, transactional tables.  I have
a
   conceptual design question.  If I have a two columns 'a' and
'b', a is
   the primary key, and b is a type double, in table 1 (T1) for
which
   column b will have many NULL values, do I leave it with an allow
null
   constraint on the column or pull the column and place it into
table 2
   (T2) with a foreign key, making a simple optional one-to-one
   relationship.  Over the course of time, as the table fills with
records,
   will a column w/ many NULL values have a detrimental effect on
   performance or maintenance with regards to the DB?  Am I missing
   something here in DB design 101, by leaving the column in the T1
and
   knowing it will only be populated 7% of the time; what are the
major
   implications based on the RDBMS and engine I'm using?



   Do I go to 2nd NF simply because a column is not going to be
populated
   as often?



   Max H. Thayer

   Lead Software Developer

   Center for High-Throughput Structural Biology



   Hauptman-Woodward Medical Research Inst.

   700 Ellicott St.

   Buffalo, NY 14203

   Phone: 716-898-8637

   Fax: 716-898-8660

   http://www.chtsb.org http://www.chtsb.org/

   http://www.hwi.buffalo.edu http://www.hwi.buffalo.edu
http://www.hwi.buffalo.edu/









Re: [PHP-DB] DB Design Concepts

2007-05-02 Thread Chris

Max Thayer wrote:

I'm using MySQL 5.x InnoDB engine, transactional tables.  I have a
conceptual design question.  If I have a two columns 'a' and 'b', a is
the primary key, and b is a type double, in table 1 (T1) for which
column b will have many NULL values, do I leave it with an allow null
constraint on the column or pull the column and place it into table 2
(T2) with a foreign key, making a simple optional one-to-one
relationship.  Over the course of time, as the table fills with records,
will a column w/ many NULL values have a detrimental effect on
performance or maintenance with regards to the DB?  Am I missing
something here in DB design 101, by leaving the column in the T1 and
knowing it will only be populated 7% of the time; what are the major
implications based on the RDBMS and engine I'm using?


What kind of queries are you going to be running? Where you need both 
columns all the time?


I'd suggest leaving them in the same table for a few reasons:

- If you're always joining the two tables there's no point in having 
them separate.


- If you always need the NULL entries, you're going to have to LEFT 
OUTER JOIN the two tables every time because table '1' will have an 
entry but table '2' might not.


- You're going to gain performance with large datasets because the 
database (mysql or any other type) doesn't have to join two tables and 
match up entries and so on.



If on the other hand you are going to have a script that runs once a 
month that queries both tables, this is all moot.



Is there another way you can do what you want? eg a stored procedure? 
http://dev.mysql.com/doc/refman/5.0/en/stored-procedures.html


--
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] DB Design Concepts

2007-05-02 Thread bedul
actualy i'm not soo smart..
 Max Thayer wrote:
  I'm using MySQL 5.x InnoDB engine, transactional tables.  I have a
  conceptual design question.  If I have a two columns 'a' and 'b', a is
  the primary key, and b is a type double, in table 1 (T1) for which
  column b will have many NULL values, do I leave it with an allow null
  constraint on the column or pull the column and place it into table 2
  (T2) with a foreign key, making a simple optional one-to-one
  relationship.  Over the course of time, as the table fills with records,
  will a column w/ many NULL values have a detrimental effect on
  performance or maintenance with regards to the DB?  Am I missing
  something here in DB design 101, by leaving the column in the T1 and
  knowing it will only be populated 7% of the time; what are the major
  implications based on the RDBMS and engine I'm using?
can we see your table??
u can use my way for your problem. if you have access.. the lowest is fine.
I create the table from there and then i use relationship.

 What kind of queries are you going to be running? Where you need both
 columns all the time?
i ask same things.. hope my zip can help u

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