[PHP-DB] PHP MySQL High CPU on Query

2012-06-12 Thread David Christensen
I have a situation where a query run from PHP/Zend Framework on a MySQL
database seems to hit the CPU harder than the same query run via the
MySQL command line.

The query is a simple SELECT statement querying 2 tables, 12 columns
with a short WHERE clause that filters the results to less than 100
records.

ZF is using the PDO adapter.  I've seen the query cause mysqld to show a
spike up to 50+% cpu while the query is run from a PHP call, and the
same query from the client barely nudges the process to 1%.

Is there something I can do to gather more data on what's going on and
why this is happening?  I'd expect some overhead, but that much of a
difference seems wrong.

Thanks for your advice,

David Christensen

=

This electronic mail is solely for the use of the intended recipient, 
and may contain information that is privileged, 
confidential and exempt from disclosure under applicable law. 
If the reader of this message is not the intended recipient 
– whether as addressed or as should reasonably be surmised by the reader – 
you are hereby notified that any dissemination, distribution or copying of this 
electronic mail 
or any attachment is strictly prohibited. 
If you have received this communication in error, 
please do not print, copy, retransmit, disseminate or otherwise use the 
information 
contained herein or attached hereto and notify us immediately 
by replying to the electronic mail address listed above. 
After notifying us, please delete the copy you received. 
Thank you.


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



Re: [PHP-DB] Unknown column 'Test' in 'field list'

2002-03-28 Thread David Christensen

Change your query to this and make sure your ID field is set to 
auto_increment

INSERT INTO entry (user_name) values ('$name')

That'll work for sure! ;-)


Jennifer Downey wrote:

 Hi All!
 
 Hope I'm not bothering you nice people too much.
 
 I have a account called Test, when I click the submit button I get this
 error
 
 Unknown column 'Test' in 'field list'
 
 My table only has two fields id and user_name
 
 I am not trying to insert the data into the field Test but into usre_name.
 I had this problem  once before but I can't remember how I fixed it or if I
 ever did. Any ideas?
 
 
 ?php
 if($action == Submit my entry){
 if (!empty($name)){
 $enter = insert into entry (id, user_name) values (' ',$name);
 mysql_query($enter) or die(mysql_error());
 }
 exit;
 }
 $query=SELECT name FROM users WHERE uid=.$session[uid];
 $ret = mysql_query($query) or die(myasql_error());
 list($name) = mysql_fetch_array($ret);
 ?
 
 CENTERtable ALIGN=center WIDTH=80%tr
 tdform ACTION=?php  echo($PHP_SELF);? METHOD=post
 
 ?php
 print tdbrUsername: input type=\text\ value=\$name\
 name=\u_name\ size=30/td/tr\ntrtd;
 print input TYPE=\submit\ name=\action\ VALUE=\Submit my
 entry\BRBR;
 ?
 /form/td/tr
 /table/CENTER
 
 
 
 
 
 



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




Re: [PHP-DB] Contact Database php_mysql

2002-03-26 Thread David Christensen

Not so sure you need to go to that much detail in the linking of your
tables.  It's a good idea for the states, but the zip is usually just an
integer anyway, so you can just store that with the record.  Next, do
you really need Full_Name???  You can extract that from the other two
fields.  As for city, that's going to be a HUGE table.  The only
advantage to making another table out of such is if you had more data
per record and you need to search really fast.  Just store that in with
the Contact info the single table.

The way I'd do it would be like this:

[Contacts]
ID int primary key auto_increment not null
fname varchar(25) not null
lname varchar(35) not null
mname varchar(25)
suffix varchar(5)
addr1 varchar(35)
addr2 varchar(35)
city varchar(35) not null
state int not null
zip int not null

[State]
ID int primary key auto_increment not null
state varchar(25)

The field sizes are arbitrary, so think about what you're gonna need and
size appropriately.


Russell Griechen wrote:
 
 I am contemplating a Historical Database
 I barely can spel redundant let alone normalize so I am handicapped.
 The aim is to enter a name only once. I am studying linking tables.
 In the [Contact]
 idContact
 First_Name,Last_Name,Middle,Suffix,Full_Name,idCity,idState,City_State,i
 dZip_Code,
 Address_1,Address_2,
 
 [City]
 id
 Cityname
 
 id (al, ar etc)
 Statename
 
 [ZipCode]
 id
 Zip_Code
 
 Comment please,
 Russell Griechen
 
 --
 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




[PHP-DB] PHP4 LDAP

2002-03-20 Thread David Christensen

Not sure if this is the right list for this, but I didn't see any others 
on the PHP web site that made sense...

I'm using the following packages:

php-common-4.1.2-1mdk
php-4.1.2-1mdk
mod_php-4.1.2-1mdk
php-ldap-4.1.2-1mdk
openldap-clients-2.0.21-1.1mdk
openldap-servers-2.0.21-1.1mdk
openldap-2.0.21-1.1mdk
libldap2-2.0.21-1.1mdk
php-ldap-4.1.2-1mdk
apache-modules-1.3.23-4mdk
apache-common-1.3.23-4mdk
apache-conf-1.3.23-3mdk
apache-1.3.23-4mdk


I'm trying to use my LDAP server for privilege access to certain 
portions of the site.  I'm verifying the user's account information via 
LDAP and that seems to work ok, because I can bind and do a modify on 
the user's information.  I'm updating a particular field to hold the 
sessionID and a time stamp.  The record updates just fine, because I can 
do a ldapsearch from the command line on the server using the same 
credentials I use in PHP and I can see the update.

I also have the server WIDE OPEN at the moment to test.  I didn't want 
any stray ACL's to get in the way of debugging this.

The problem arises when I try to read back all of the attributes within 
the PHP script.  I can see only certain attributes: uid, mail, cn (the 
normal stuff) but if I try to read these fields that I want to use for 
the session, they don't print in PHP, but the show up from the LDAP 
command line util.  The fields include: employeeNumber, carLicense, 
departmentNumber.

Like I said earlier, I can update them from PHP, just can't read them back.

Any ideas are greatly appreciated!

David Christensen


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




[PHP-DB] Re: PHP4 LDAP

2002-03-20 Thread David Christensen

Just in case anyone was wondering, here's a bit more info.  I'm not sure 
why some attributes show up the other way though:


?

$baseDN = dc=mydomain,dc=com;
$bindDN = uid=dumbuser,dc=mydomain,dc=com;
$bindPass = mypass;

$linkID = ldap_connect(ldapServer,ldapPort);
if ($linkID)
if (ldap_bind($linkID,$bindDN,$bindPass) == false)
DO SOME ERROR PARSING

$filter = uid=dumbuser;
$search = ldap_search($linkID,$baseDN,$filter);
$entry = ldap_first_entry($linkID,$search);  #- ALL TOO IMPORTANT LINE
$values = ldap_get_values($linkID,$entry,departmentNumber);
for ($i = 0; $i  $values[count]; $i++)
print $i . : . $values[$i] . br\n;
ldap_close($linkID);

?

Now (for some reason I haven't figured out yet) if you don't do the 
ldap_first_entry() step, you cannot access all of the attribute values 
returned from the $search!

You can test by commenting it out and changing the $values line to use 
the $search value as the second arg.

I hope that helps someone.  I could have used it for sure.



David Christensen wrote:

 Not sure if this is the right list for this, but I didn't see any others 
 on the PHP web site that made sense...
 
 I'm using the following packages:
 
 php-common-4.1.2-1mdk
 php-4.1.2-1mdk
 mod_php-4.1.2-1mdk
 php-ldap-4.1.2-1mdk
 openldap-clients-2.0.21-1.1mdk
 openldap-servers-2.0.21-1.1mdk
 openldap-2.0.21-1.1mdk
 libldap2-2.0.21-1.1mdk
 php-ldap-4.1.2-1mdk
 apache-modules-1.3.23-4mdk
 apache-common-1.3.23-4mdk
 apache-conf-1.3.23-3mdk
 apache-1.3.23-4mdk
 
 
 I'm trying to use my LDAP server for privilege access to certain 
 portions of the site.  I'm verifying the user's account information via 
 LDAP and that seems to work ok, because I can bind and do a modify on 
 the user's information.  I'm updating a particular field to hold the 
 sessionID and a time stamp.  The record updates just fine, because I can 
 do a ldapsearch from the command line on the server using the same 
 credentials I use in PHP and I can see the update.
 
 I also have the server WIDE OPEN at the moment to test.  I didn't want 
 any stray ACL's to get in the way of debugging this.
 
 The problem arises when I try to read back all of the attributes within 
 the PHP script.  I can see only certain attributes: uid, mail, cn (the 
 normal stuff) but if I try to read these fields that I want to use for 
 the session, they don't print in PHP, but the show up from the LDAP 
 command line util.  The fields include: employeeNumber, carLicense, 
 departmentNumber.
 
 Like I said earlier, I can update them from PHP, just can't read them back.
 
 Any ideas are greatly appreciated!
 
 David Christensen
 



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