GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 21-Dec-2003, 03:30
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Question

About mysql_connect()'s client_flags


Previously I connected to the MySQL server via my PHP scripts like this:

PHP Code:

<?php

// connecting
$conn = mysql_connect( $host, $user, $pass );
?>


In my newer scripts, I want to try the somewhat newer client_flags parameter (available in PHP since ver. 4.3.0) but I am not sure what this paragraph means:
Quote:
The client_flags parameter can be a combination of the constants MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE or MYSQL_CLIENT_INTERACTIVE... more...
What does combination mean?

Is it MYSQL_CLIENT_COMPRESS + MYSQL_CLIENT_INTERACTIVE? Note the PLUS sign between the 2 constants, or is it a bit more complicated than that?


About 2 hours ago I modified this copy of the forum script to connect to MySQL this way:
PHP Code:

<?php
  $this->link_id = @mysql_connect( $server, $user, $password, FALSE, MYSQL_CLIENT_COMPRESS );
?>


Anybody notice anything different...?
  #2  
Old 21-Dec-2003, 03:42
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
I think that you can split the tags with a comma (, )
never tried tho, but thats where testing systems come in place

about the compress thing..
In my eyes compressing the MySQL data is not needed when MySQL is on the same server as your site.
compressing always means a bit more processor usage so pages will slow down..
but whats the use of that when you MySQL on the same (fast) server.

It's about the same with CVS.
you can set compression, but setting it to high only slows down the server, which makes the compression useless

[added]
Just checked the mysql.c file
it seems that PHP just passes the client_flags to mysql, so you will have to look at the MySQL manual for those flags i guess
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #3  
Old 21-Dec-2003, 03:48
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Quote:
Originally Posted by Allowee
I think that you can split the tags with a comma (, )
never tried tho, but thats where testing systems come in place
That was the first thing I tried; and no, it doesn't work!
Quote:
about the compress thing..
In my eyes compressing the MySQL data is not needed when MySQL is on the same server as your site.
compressing always means a bit more processor usage so pages will slow down..
but whats the use of that when you MySQL on the same (fast) server.

It's about the same with CVS.
you can set compression, but setting it to high only slows down the server, which makes the compression useless
You know me, if it's something to do with compression, I want to figure it out. ...
  #4  
Old 21-Dec-2003, 03:55
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
i was a bit late adding what I found in the .c file (see post above)

I just took a look at the MySQL manual
http://www.mysql.com/doc/en/mysql_real_connect.html

also no help, they talk about a combination

have you tried just adding a space between the flags?
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #5  
Old 21-Dec-2003, 04:00
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I am embarrased to admit it but YES, I tried the commas, the spaces and finally ONLY the PLUS signed worked... well, it didn't complain when I added the plus sign!

... so that must be it!
  #6  
Old 28-Dec-2003, 07:18
sdeming sdeming is offline
VIP
 
Join Date: May 2003
Location: Michigan, US
Posts: 8
sdeming will become famous soon enough
Jay,

Try separating the flags with pipes:

MYSQL_CLIENT_COMPRESS | MYSQL_CLIENT_INTERACTIVE

This applies the binary OR operator to each value sending the result to the function. I'm not sure what the actual values of these two fields are, but say they are 8 and 16 just for kicks. 8 = 00001000 and 16 = 00010000, so 8|16 = 00011000. Notice how both flags are now turned on (the 1's)?

Actually, you get the same result using + instead of | but if any of the client_flags span multiple bits then you will see some differences.
  #7  
Old 28-Dec-2003, 10:39
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Thank you Scott, that was it! I've ALWAYS wondered what the php CONSTANT values meant or how I am supposed to use them - now your bit operator example puts a whole new perspective on things... finally!
 
 

Recent GIDBlogToyota - 2008 July Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:09.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.