How To Retrieve Error Information
There are two functions that are useful for retrieving MySQL errors.
mysql_error()
string mysql_error ([resource link_id])
The above function returns the error message generated by the last MySQL function, or returns an
empty string if no error occurred. On using the optional link_id parameter, the most recently
occurring error generated from that identifier will be used; else, the most recently opened
server link is assumed.
- Kiran's blog
- Add new comment
- Read more
- 165 reads
SELECT INTO OUTFILE - MySQL
The SELECT INTO OUTFILE SQL statement is a type of the SELECT query. Generally used when you need to direct query output to some text file.
The syntax format:
SELECT [Your select options] INTO {OUTFILE | DUMPFILE} filename EXPORT_OPTIONS
FROM table_references [Your additional select options]
Using OUTFILE option causes the query result to be output to the text file. The formatting of the query result is dependent upon how the EXPORT OPTIONS. The EXPORT OPTIONS actually determine how the table fields and lines will be
delimited in the outfile.
- Kiran's blog
- Add new comment
- Read more
- 1032 reads
Full-text indexes in MySQL
Full-text indexes are user for searching text stored in CHAR, VARCHAR, or TEXT datatypes.
Making a full-text index is quite similar in making indexes of other types.
As an example, let’s create a table called name, indexing its lastname column using
the full-text variant:
CREATE TABLE name ( ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, firstname VARCHAR(75) NOT NULL, lastname MEDIUMTEXT NOT NULL, FULLTEXT(lastname), PRIMARY KEY(ID));
As you can see creating full-text indexes is much like creating other types of indexes.
- Kiran's blog
- Add new comment
- Read more
- 188 reads
Mysqldump backup class
Here is a simple class to create backup of your mysql database and email it as an attachment.
class mysqldumpbackup
{
var $host;
var $user;
var $password;
var $dbName;
var $emailTo;
var $emailFrom;
var $subject;
var $message;
var $fileName;
var $dateNtime;
function attachment_mail()
{
$file_type = "application/octet-stream";
$file = $this->pathToAttach;
$start= strrpos("$this->pathToAttach", '/') == -1 ? strrpos("$this->pathToAttach", '//') : strrpos("$this->pathToAttach", '/')+1;
- Kiran's blog
- Add new comment
- Read more
- 287 reads
mysql_query vs mysql_unbuffered_query
mysql_query
Execute a query. Statement is:
$resultset = mysql_query( $query[, $con] )
mysql_query executes SQL query using the most recently opened database connection.
The sencond agrument is specific server connection.
If query is a SELECT query, on successful, it returns a result set variable
which can be used with functions like mysql_fetch_row to retrieves the contents of the
result set. However, if query is non-SELECT query like as INSERT, UPDATE or DELETE
- Kiran's blog
- Add new comment
- Read more
- 468 reads













