Friday, July 2, 2010

PDF to SWF converstion through PHP

I want to share this to you all. I was struct to convert PDF to SWF from PHP using EXEC() function. Problem i faced is the folder name with white spaces. I was tried all the poosibilities. Finally I catch the solution. The code i used is


<?php
// Syntax: exec('path_to_exe "path_to_source_PDF_file" -o "path_to_converting_swf_file"');
// I missed the double codes (") in the path_to_source_PDF_file and path_to_converting_swf_file. Hence the conversion not happened.
// Example: [ I used SWFtools to convert PDF o SWF]
exec("C:\\SWFTools\\pdf2swf.exe c:\\test.pdf -o C:\\navneeth.swf");
?>


I hope this will help to someone.

Wednesday, April 21, 2010

Drupal Site offline page theme

To enable offline theme add the following line in settings.php

<?php
$conf['maintenance_theme'] = '<themename>';
?>

Now the site is ready with offline theme. Drupal provides contributed offline theme to use. Click here http://ftp.drupal.org/files/projects/offline-6.x-1.1.tar.gz to download offline theme.

Monday, November 2, 2009

Keep in mind when using Left Join

The WHERE clause would be false in the following query if tableB.column1 were NULL:

SELECT * FROM tableA LEFT JOIN tableB ON (column1) WHERE tableB.column2=5;

Therefore, it is safe to convert the query to a normal join:

SELECT * FROM tableA, tableB WHERE tableB.column2=5 AND tableA.column1=tableB.column1;

Friday, October 30, 2009

Group by in custom query in drupal

We should Keep in mind the followings when we use group by in custom queries.

ex: SELECT pname, MIN(price) FROM products GROUP BY pname;

1. The column that you GROUP BY must also be in your SELECT statement.
2. Remember to group by the column you want information about and not the one you are applying the aggregate function on. In our above example we wanted information on the pname and the aggregate function was applied to the price column.

More Mysql Indexes affect performance on heavy traffic site

I want to share about index on table columns. Indexes are something extra that you can enable on your MySQL tables to increase performance, but they do have some downsides. When you create a new index MySQL builds a separate block of information that needs to be updated every time there are changes made to the table. This means that if you are constantly updating, inserting and removing entries in your table this could have a negative impact on performance. So avoid using index unnecessarily. That will affect the performance.

Thursday, August 20, 2009

Check the user submitting date

checkdate() is a function to check the date is valid or not.

eg:
var_dump(checkdate(12, 31, 2000)); // return true
var_dump(checkdate(2, 29, 2001)); // return false

Tuesday, June 2, 2009

Drupal watchdog query into file

To avoid record growing in watchdog table I am doing the followings. outfile in mysql is used to write output in a file.
I am using following code to write watchdog output into file.

<?php
function customfunction() {
$datetime = date("Y_m_d_Hi");
$path = "c:/";
db_query("SELECT wid,type,uid,message,severity,link,location,referer,hostname,timestamp FROM watchdog ORDER BY wid DESC LIMIT 0,10 INTO OUTFILE '".$path."watchdog".$datetime.".csv' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' ");
}
?>