Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Fastest MySQL Functions


i was wondering if anyone knows what the fastest mysql functions/libraries there are. i was reading that mysqli is up to 40x faster than mysql, but wasn't sure if i should use the object vers or just the function based ones.. also, if there's anything faster?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Fastest Way To Format MySQL DATETIME In PHP 5
You've got a MySQL DATETIME string that you pull out of the db as a variable.
Why? Because you're cool. And, because this DATETIME is so hot right now.

Our DATETIME looks like:

2007-10-13 03:47:05

But you want it to take off its clothes and get it to look like:

3:47:05
=================================================
What line(s) would you use on this skanky little DATETIME to get it how you want it? Its the speed that's key here, boys. We all know you can pull out and use a lame ass substring function. But we should all be above that by now.

Fastest Way To Look For An Array Of Char?
If I have a string, (variable len), and I am looking for the first position
of one char in array starting from position 'x'

For example,

// the 'haystack'
$string = "PHP is great, php is ok";
// the needles
$char[] = 'P'
$char[] = 'r'
$char[] = 'k'

I would search the $string for the first $char starting from 3 and it would
return 7, (for 'g').

I could use many strpos(...) but that does not sound very efficient.
So what would be the fastest way to get the first position?

And, I am using PHP 4.x, not 5, (otherwise I guess I would use strpos(...)).

Fastest Way To Read URLs.
I would like to know what is fastest way to read contents of web page? I would like to know what possibilities are there. Currently with "file_get_contents()" reads around 10-13 pages in 30 seconds (Default max execution time). I know I can change max execution time so it can read more pages but I would like to find another way if it is possible...

Also I would like to know is it possible to print out the results while still loading page? Maybe it is browser(my settings), php setup or script fault so I'm not sure.

Fastest Way To Do Database / Array Search
I am trying to write a script that allows users to search through a
database of names. But rather than give a search string and then return
all those that match, I would like it to search each time the user
types a new letter in the text box.

That's badly explained - this example might help!

The user types "r" and I displays all the names with r in them. The
user continues and types "i" so the textbox shows "ri" and displayed
are all the results with "ri" in them. I as doing currently this by
re-querying the SQL database where the names are hosted but it takes
too long to query, return and refresh the page.

What would be a better way of storing this database info to allow a
faster search? Maybe load it into a PHP array first (stored in another
file) and search within that? (Can you do 'clever' searches in PHP?) Or
into a javascript array? The list could be upwards of 1000 names.

The databse shouldn't change that often so I could have a script that
updates the array every 24 hours or every time a new name is added.

Fastest Way To Print All Database Entries?
Say I have a database with 1000 entries. What's the fastest, dirtiest way to do that.. Like this? PHP Code:

What Is The *fastest* Method To Extract Directory From Url ?
given is string:

http://www.server.com/dir/dir2/dir3/file.html
or
myname@domain.com

and result should be:

http://www.server.com/dir/dir2/dir3/
or
myname@

how to make it *really fast* without strrev and strstr ?

Which Fetch Is The Fastest Mysql_fetch_ Array,assoc Or Another?
I think the title says it, but I'm wondering if i'm only using an associative key should i just use assoc or is the speed so minimal it don't matter?

PHP MySQL Functions
Does anyone have any php funcitons already written for querying the database etc..?

MySQL Functions Are Undefined
I have php4 and mySQL. When I call a mySQL function such as mqsql_connect() I get ERROR undefined function.
Please help, THe dll is in the folder but I have no idea how to resolve this, other people have also had this problem.

Php Mysql Api Functions - Speed
is there a difference in script overhead/speed when using mysql_fetch_array vs. mysql_fetch_object? Is there a reason to use one over the other in any given circumstance?

PHP Is Not Recognizing MySQL Functions
Whenever I try to use a mysql function (such as mysql_connect("localhost","root","mypassword") with mypassword being my actual password), viewing the page in mozilla reveals this error message:

Fatal error: Call to undefined function: mysql_connect() in /var/www/html/index.php3 on line 14

I'm pretty sure that this means it has no definition for that function, and thus can't execute it. It does this for all mySQL stuff. I am doing this on a 9.1 Mandrake Linux installation with PHP v. 4.3.1 and mySQL 4.0.14. To install mySQL for PHP, I used
urpmi php-mysql as suggested by my phpinfo() page. Both PHP and mySQL work fine on their own, just not together.

Mysql Time Functions
This represents 2 fields in a mysql database
[login] => 2005-08-22 18:04:41
[logout] => 2005-08-22 18:05:08

I want to find out the difference between these 2 times.
I don't have access to mysql's DATEDIFF function.

How do I do this ? Its there perhaps, a web page that explains how ?
I have looked at the date and time functions of the mysql manual but i
don't understand it.

PHP Version 4.2.2 Mysql Functions
I have a collectionof PHP/MySQL scripts that used to work great when I was using PHP 4.0.x. However I recently 'upgraded' to version 4.2.2 and none of them work. I looked through php.net for info on this, but couldn't find what I was looking for.

The script below works great on my old version of PHP, but I am always getting a "mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/htdocs/xxx/xxx.php on line 24" The script looks like this: Code:

Arrays And While Mysql Functions
How can I get this array to work? I am trying to add data to an array for every row of data? This is a sellection of queries that I need to parse into an array so a function can use the arra to draw a graph. I am new to arrays how can I get this to work? Code:

Mail Functions And MySQL
Okay I have created a script that post user information to mysql database. Now I would like to be able to send a webpage to each user based on there place and state, but the code below sends to one user multiple pages.

What is wrong with this code or is there something better to use to do this? ....

Data/math Functions With Php/mysql
Hey everybody, I have a tricky problem that i need to solve... I'm currently using apache/php/mysql , developing a custom ticket system... now i'm working on one of the final parts which are reports...

here is the scenario: I have a few rows of dates, such as when a ticket was opened and when that same ticket was closed...

ie: open_ticket, closed_ticket

I need to calculate the number of days it took me to complete each ticket, then i need to calculate the MEDIAN time it took me to complete tickets...

see, kind of tricky, I noticed that mysql can do averages, but can it do MEDIAN values?

MySQL: External SQL Functions Exported By DLLs
Sorry for being a little off-topic, but I guess PHP
users are often MySQL users too.

We have a few rather advanced calculation routines
developed in C++. Currently we are using a Sybase ASA
database for our app. and these routines are accessible
by so called external functions exported by a DLL
(dynamic link library) that we wrote in C++. Sybase
supports this quite nicely.

The client app can call such routines by:

"select get_roof_angle() as angle from dummy;"
or
":angle = call get_roof_angle();"

Now we are checking if other databases can provide us
with similar abilities. So I just wonder if MySQL
supports the ability to call a routine exported by a
DLL? If yes, does anyone know the SQL syntax to declare
it in MySQL.

PHP Needs To Clear Memory After Making Mysql Functions?
I use $result=mysql_fetch_array(...), I need to clear memory there or it happens automatically?

Session.save_path Appears To Affect Mysql Functions
I was installing a script did not want to place session variables in
the standard php directory.

After changing the session_save_path in the scripts .htaccess file, the
mysql_connect stopped functioning, function_exists('mysql_connect')
returned False. I suspect the whole mysql library stopped functioning.

Is this a known bug in PHP's mysql handling?

DBM Functions:: Undefined Functions Error
I have been trying to use the DBM Functions (dbmopen etc) in php but always get an undefined funtion error. Do I need to load something or change something in the .ini file to get it to work?

thanks
MIke

Do We Need This Functions?
I'd like to check with others what are the least used functions in PHP, since I think that it is becoming more and more filled with unuseful addons while missing useful extensions like SOAP (to name one).

PHP Functions
I have a serious problem, that I hope you here at DevShed can help me out. I have been using PHP for a while now and I love it, I think its a great language. I have learnt quite a lot already...but there is one thing that I have had trouble with and thats writing my own FUNCTIONS!

Im fine with the built in functions etc, but I just cant get my head around bloody USER DEFINED FUNCTIONS!

I have read books, completed many tutorials and just when I think I have it sewn up, something else crops up and Im back where i started.

I would be very grateful if someone could take me through the workings/example of a custom function.

e.g - echoing in a function, returning values.

Using PHP Functions On Different Url

I want to extract the size of images located at a different url

Is it possible to use the GetImageSize() function to do this?

from http://www.site1/myscript.php I have tried -

$url = "http://www.site2/image_name.jpg" ;
$size = GetImageSize($url);

But I get a error.

Is there a way of using functions such as GetImageSize(), chdir(), etc from one site to extract data from another site?

Both sites are mine and I have made the directories 777

The reason I want to do this is because I hold 100's of images on one site, but wish to use them on a second site without having to keep copying over all the images as it will be difficult to keep up to date.

But I need to use php to extract and minipulate the images before displaying.

Does any kind php guru know a way of doing this?

XML Functions With PHP
Anyone know where I can find some tutorials or good usefull examples on parsing XML with the XML functions? I really need help with this stuff, but I cant find any docs anywhere, help would really be appriciated.

C Functions To Use With PHP
We have a bunch of C and C++ functions pre-developed in our organization.

To make a web frontend, we would like to use PHP but we don't want to recode all the C functionality.

I recall reading a while back in the manual that C functions can be integrated into PHP, compiled perhaps, but I cannot seem to find it now.

Php-functions
Do any of you know if PHP supports a function to check a file. A same sort of function like in an Unix-environment the function "file" is: to check what kind of file a specific file is.

Functions
Is it possible to install new functions without reinstalling PHP,on a unix system?

XML DOM Functions
What about actually creating an xml doc on the fly, and saving it out. Does anyone know of any info or examples on this to point me to before I go hacking away with nothing but the xml dom function info from the manual? The manual is great, yes, but its usually the user comments that help in figuring this stuff out, and nobody talks about creating xml documents.

Functions!!
What I've done is I've got some code which displays the question and the wrong answer, however I'm trying to email the user who has set up the quiz, the info, which includes the wrong questions.

The thing I don't want to repeat the code, but rather place this in a function, but it looks rather tricky, when I try to implement this. Code:

Min And Max Functions
If I have a series of integers, how do I get the minimum (or maximum) value
NOT equaled to 0?

Web Functions?
I'd like to post some news content on my web page from another website. Are
there built in php functions that will allow me to do this?

Using Functions
I have this project and so far this is what it's suppose to do:
There are 4 pages.  The first page asks the user to enter their username and password (these are finite and defined by the second page) and asks the user to choose a file they want to work with.  The second page verifies the username and password are correct and echoes the information from the chosen file into a table and has two links underneath: one to take the user back to page 1, and the second to take the user to page 3.

Page 3 calls in two functions from page 4 to loop through all the information in that same file using regex to make sure Student Numbers and email addresses are in the correct format.  If it's correct, it will alert the user that all the information is legitimate, or else it will write the errors to a log file.  What I'm having trouble with is on page 3 and 4.  The functions aren't working because Apache says there are undefined variables, and on page 3 I can't seem to get rid of the array to string conversion notice. Code:

Sql Functions
i know:

year()
month()

is there one for week, ive tried week() but I cant seem to get it to work, is there a site I can look at sql functions?

MS-SQL Without Functions?
Within the following environment:
* MS Windows NT 5.0 web server
* MS-SQL database server
* PHP Version 4.3.3 (with MySQL functions, but without MS-SQL functions)

... is it possible AT ALL possible to connect to a database if my pages are all *.php?  I asked the sysadmin to configure PHP's MS-SQL functions, but he felt that it would require too much modification of the server.  He suggested I use ASP... is that even possible without switching all the files to *.asp (and making the existing PHP scripts useless)?

Functions
i've seen on alot of forums, such as PHPbb2, that in their template files, they use lines such as <!-- BEGIN switch_user_logged_out -->  I was wondering if you use functions to do that and if so, how?

Functions...
I'd like to ask two questions:

1) How can I include functions located on other files?
2) How can I make a function modify the values of passed variables?

I'm guessing there's something with references, but I'm not familiar with this concept on PHP, I just know C++ pointers, so if there's any good paper on it.

Writting Functions
Where does one learn about adding functions to PHP, not for development, more for personal, I know how to write functions in a PHP script, but where can I learn to write "global" functions?

Rename Functions
I run a site which loads images using PHP and MySQL to store the image information. Currently the system works as such:

- A table stores the name of the image, which basically is just the main part of the image filename that is loaded when you click on a link. eg table entry = "image1", the filename that is called on the site is "image1.jpg" so clicking the link shows that image.

Anywho... I'm looking to change the system so that the images are named as per the ID number in the table, so instead of "image1.jpg" it might be "0001.jpg".

So my question is this:

Is there a way that, when the image is loaded, I can create a button or link of some kind below it that says "Click here to save the image", and this would then rename it to the name field when they are saving?

eg

Table entry:
ID - 115
Name - image1

Image loaded:
115.jpg

So when they right-click to save that image, it will prompt to save it as "115.jpg" by default, which I don't want. I want the button to get the 'proper' name, eg image1.jpg, and put that in the box when saving, automatically.

I hope that makes sense, it's kind of hard to explain...

Does anyone know how this could be achieved if at all possible? Any help would be great!

Using The File Functions
I am working on a script that w3ill be used to create redirects or gateway pages etc.

The script creates a directory, then places a index.htm file insidce the created directory with database variables and a meta-refresh in the head of the HTM file. The creation of the dile is not the problem.

What I would like to know is how would I go about editing this file??

If someone logs in to the admin screen and edits the database entry for this redirect, what would be the easiest way to update the contents if the file??

Would it be easier to overwrite the file, or is there a way where I can open the file, read the file into a buffer until it finds what I want changed, make the change then move to the next point(Different Variables)?

Variables Within Functions
I had a bit of script which passed a variable to itself using GET variables. I changed it so that the <FORM> tag of the page was inside a function. Since then, the $HTTP_SERVER_VARS['PHP_SELF'] variable returns nothing.

Is it commonly known that this variable doesn't work inside a function? And how can I get by this (apart from passing it into the function).

p.s. I realise you can use $_SERVER variables, but i have to use this older version of PHP cos my ISP wont upgrade it quite yet!

Certain Functions Don't Work
I have just installed php on windows 2000 and it's working fine. But there are some functions that work and some that don't.
For eg: "mysql_fetch_array" will work fine but "in_array" will not work. Is there something more that I have to install so that these functions too can work?

Ssl In Socket Functions
Can I create ssl connection through the socket functions (not fsockopen)?

IMAP Functions
I have signed up with a new web host and want to use IMAP functions with them. They do support these. I have checked. They have provided webmail at url:

http://webmail.mydomain.com

so I guessed that I should use this syntax in my php script:

imap_open("{webmail.mydomain.com:143 INBOX", "username", "password");

But it does not work. I receive this error message:

Warning: imap_open(): Couldn't open stream {webmail.mydomain.com:143}INBOX

Help! I have asked my host about this and from their reply I dont think they even know what IMAP functions are. So, I am really stuck. I have read about opening an IMAP stream and that there are different syntaxes for different software components and scenarios - how can I find out which one is appropriate for my set up, given that asking my host is out?

The webmail is horde webmail. The login url is below

http://webmail.mydomain.com/horde/

I am on a virtual server. So, I have an IP - but it is a shared IP of course. My host provided me with 3 IPs - one for FTP access, one is just my private IP (behind a firewall), the other is a public IP (outside the firewall). I have to give my public IP to DNS.

Image Functions In Php?
I have seen some images (banners.etc) that have a src like
<img src='http://url/file.jpg?bla=bla&blabla=blah'> im assuming that the src isnt really an image but a script that echos out an image. my question is, on the server. the file extension is jpg... do u make your script executable and give it a jpg extension or what? how does on accomplish this?
also, could anyone point me in the direction of a server that supports the image functions in php? i currently am storing my scripts at http://hobbiton.org where they have php installed as a cgi. but with no image support...they provide 50mb free... so this is a pretty good server.

Calling Functions
Could someone out there give me information on how to call a function from a click event? Is it possible to do in PHP or do I need to write it in javaScript? What I would like to do is click the next record button and have all of the fields in my form change to hold the data of the next record in the table.

Functions Postgesql
can someone tell me the equivalent of the following function in postgesql from mysql functions:

1.mysql_result
2.mysql_data_seek
3.mysql_fetch_field
4.mysql_errno()]
5.mysql_error()
--------------------


Need Help Writing Own Functions
I would like to try writing my own functions, so as to keep some code
within the same PHP file rather than make multiple PHP files.

What I am having a problem is is how to call a function when a php
generated HTML form is "submitted" and to put the variables back into
another function within the same PHP file.

I have figured how to pass variables to a basic test function I wrote, but
not how to call a function within the same PHP file AND from a form.

Can't seem to find any good examples online.

Openssl CSR Functions
I have been playing with the openssl functions in php, but cannot figure out how to decode a csr. eg. I generate a csr then want to check the details are correct before submitting to ca?

Mail Functions In Php
i am using mail function in PHP.the mail address is a variable.Mail address will known at run time. My doubt is how to find out whether the mail address exists or not?

It had been specified in the PHP sites like mail function returns boolean value. I specified some address like mail(z@388dkd.com,"subject","message");it returns true.What's the way to find whether the domain exists or not?


Copyright © 2005-08 www.BigResource.com, All rights reserved