Cursor Action Without a Cursor





ranking Sort Sort   |   date Sort Sort   |   member Sort Sort
Syndication

« Previous 1 2 3 Next »
7
Date Submitted Wed. Apr. 4th, 2007 8:52 AM
Revision 1
Helper ushi
Tags Anti-Injection | Class | Database | mysql | PHP
Comments 6 comments
A simple MySQL class for use in PHP.
Feel free to suggest improvements.
2
Date Submitted Thu. Oct. 5th, 2006 8:48 PM
Revision 1
Helper Thomas
Tags MSSQL
Comments 0 comments
Often when inserting information in a database we need to know the value of the autonumber/identity field so that we can insert related data in another table. MSSQL Server provides a SCOPE_IDENTITY() function for just such a purpose (PHP/MySQL users have the mysql_insert_id() function -- lucky).

*This is in the generic section because there is no MSSQL Server or Database section.
8
Date Submitted Wed. Aug. 30th, 2006 11:54 PM
Revision 1
Beginner smallshellscript
Tags bash | com | mysql | sh
Comments 0 comments
This little tool is pretty useful for administrators who wear the hat of both system admin and DBA on Linux/MySQL boxes. I wrote it as kind of a joke for our Perl developers, but now I use it just about every day for everything from at prompt hackups to full on table space utilization monitoring scripts.

The snippet has the library script that you can source into scripts that actually do work, as well as a script that uses the functions in the libraries. Anyone who has used the C API should be able to relate to using this script.

It's pretty fast and lightweight. It makes only one external call to mysql and sed per query. The rest is all bash builtins. Requires bash > 3.0
6
Date Submitted Sun. May. 20th, 2007 4:51 AM
Revision 1
Scripter SecondV
Tags "mysql class" | Database | mysql | SQL
Comments 0 comments
This class is a MySQL database access wrapper. It can:

- Connect to a MySQL server
- Execute SQL queries and retrieve single value results or return result rows into arrays
- Return the last inserted table row identifier, the number of result rows and the number of affected rows
- Count the number of executed queries
- Lock and unlock tables
- Escape text literal values or like patterns
- Retrieve database access errors
0
Date Submitted Wed. Nov. 12th, 2008 9:57 AM
Revision 1
Beginner nostromo
Tags mysql
Comments 0 comments
Cuando concatenamos varios campos con CONCAT( Campo1, Campo2,... ) si algún valor es NULL no se realiza la concatenación, para concater campos (aunque algunos tengan NULL) usaremos COALESCE que devuelve el primer valor que no sea null de la lista.
Asi le pasaremos una listca con el nombre del campo seguido de "", si el campo estava lleno, devuelve el campo, si es null devuelve el segundo, es decir ""
-7
Date Submitted Fri. Feb. 17th, 2006 4:52 AM
Revision 3
Helper mercutio
Tags mysql
Comments 0 comments
I use this method for keeping my sql templates away from my code.

You can extend upon the idea, as I have done in the past, by placing SQL handing classes between your scripts and the template library.

Things to note here:

The lesser userd heredoc string method. The reason this is used is to keep the SQL clear and well laid out, and not as messy as using quotes.

vsprintf() is a very handy function if you don't want to hard code the number of parameters to interpolate your string with.

The use of sprintf templates offers you additional security. For example, only allowing numbers to be placed where a %d falls. This, of course, shouldn't be the only security on user supplied variables, but comes in extra handy for debugging purposes.

Regarding the TODO in there, it would take a check of the number of % placeholders there are in the template. One caveat is remembering to remove the count of %%'s that appear (the literal percentage).
5
Date Submitted Tue. Feb. 27th, 2007 5:45 AM
Revision 1
Helper lolfejs
Tags mysql
Comments 0 comments
How to connect to your mysql serve
8
Date Submitted Mon. Oct. 23rd, 2006 7:59 PM
Revision 1
Helper lgrover
Tags my.cnf | mysql | optimization
Comments 0 comments
When ByteMyCode was crashing because of the traffic load, we started optimizing MySQL. The server had a load of >50 but the processor was all tied up in IOWAIT. We realized that the database was the source of the bottleneck so we increased all of the cache sizes. Now, it is really fast.
-8
Date Submitted Tue. Nov. 7th, 2006 11:06 AM
Revision 1
Helper kahotep
Tags mysql | PHP
Comments 6 comments
This class is a simple authentication scheme which makes it easy to add authentication to any page by including one class and adding one table to your MySQL database.

The following functions are employed by this authentication class:

auth()
this is the default constructor; it automatically checks for the POST vars "username" and "password", it also checks to see if the user passed the GET variable "logout", which would prompt it to set the authentication status to un-authenticated.

is_authorized()
Checks the SESSION variable "authorized" and returns true or false depending on that variable.

mysql_bind()
This is automatically called by the constructor each time the class is instantiated and $_POST['username'] and $_POST['password'] are present. It queries the db for a valid username and MD5 encoded password.

user_create($username,$email,$password)
Creates a user, if the username is available, and creates an MD5 hash based on username, password and date, to be used in the "activation" of the account.

user_activation_message($username)
Sends the custom activation message to the email address for the username specified

user_activation($activation_hash)
Checks to see if the activation hash is valid, if it is, the activation_hash variable is set to NULL, thus signifying that the account is active.

user_password_change($username,$password_old,$password_new)
Quick and easy way to change the user's password with one function call.

user_logout()
Sets the authorization status in $_SESSION['authorized'] to FALSE

is_username_available( $username )
Returns TRUE or FALSE depending on whether or not the username is free.
0
Date Submitted Mon. Oct. 13th, 2008 11:10 PM
Revision 1
Beginner jmardones
Tags mysql
Comments 0 comments
this snippet show how to set up passwords in a mysql console.
« Previous 1 2 3 Next »