Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

save and load query file / folder for jquery.sqlbuilderdemo-0.06.js

Posted on 2010-09-20
5
Medium Priority
?
541 Views
Last Modified: 2012-05-10
Hi,

I'm using this plugin sqlbuilderdemo-0.06.js
http://plugins.jquery.com/project/SQL_QUERY_BUILDER
I'm looking for a way to save and load the query file in a specific folder instead of the root folder.

Here is the code

<?
switch($_REQUEST['op']){
 case 'load':   
   $ff=join('',file(stripslashes($_REQUEST['reportname']).'.'.$_REQUEST['reportid'].'_sql'));
   echo $ff;
 break;

 case 'save':
   $querytosave=stripslashes($_REQUEST['querytosave']);
   $fd=fopen($_REQUEST['reportname'].'.'.$_REQUEST['reportid'].'_sql','w');
   fputs($fd,$querytosave);
   fclose($fd); 
   echo $_REQUEST['reportname']." saved...."; 
 break;
  
 case 'list':
?>
  <ul class='treeview' id='treeview_<?echo $_REQUEST['reportid'];?>'>
	<li class='list'>Saved sql files
		<ul>
<?
if ($dh = opendir('./')) {
        while (($filenm = readdir($dh))) {
            if(strstr($filenm,$_REQUEST['reportid'].'_sql')){
                 $parts = explode('.',$filenm);             
    			 echo "<li class='item'>".$parts[0]."</li>";              
            }            
        }
        closedir($dh);
}
?>
		</ul>
	</li>
  </ul>  

<?  
 break;



}

?>

Open in new window


I have edit this line
if ($dh = opendir('./')) {
to
if ($dh = opendir('./reports')) {

but it's not saving and loading from there it's only displaying the content in the tree list if I put a file inside manually

Thanks
0
Comment
Question by:lenamtl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 8

Accepted Solution

by:
ropenner earned 2000 total points
ID: 33796593
These three lines would need to change

line4)   $ff=join('',file(stripslashes($_REQUEST['reportname']).'.'.$_REQUEST['reportid'].'_sql'));

line 10)   $fd=fopen($_REQUEST['reportname'].'.'.$_REQUEST['reportid'].'_sql','w');

line 22)   if ($dh = opendir('./')) {

perhaps set a variable at the top just after <?

$basedirectory = "./someotherdirectory/";

line 4 becomes
$ff=join('',file($basedirectory."".stripslashes($_REQUEST['reportname']).'.'.$_REQUEST['reportid'].'_sql'));

line 10 becomes

$fd=fopen($basedirectory."".$_REQUEST['reportname'].'.'.$_REQUEST['reportid'].'_sql'),'w');

and line 22 becomes

 if ($dh = opendir($basedirectory))

Whatever you do you will need to reference that new directory in each of the three routines
LOAD
SAVE
and the Directory LIST

0
 
LVL 26

Author Comment

by:lenamtl
ID: 33810489
ok I will give it a try and get back to you tomorrow

Thanks
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33817320
Hi,
I'm getting
Parse error on
$fd=fopen($basedirectory."".$_REQUEST['reportname'].'.'.$_REQUEST['reportid'].'_sql'),'w');
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33824528
Ok I have found the problem

there is an extra )
$fd=fopen($basedirectory."".$_REQUEST['reportname'].'.'.$_REQUEST['reportid'].'_sql'),'w');
should be
$fd=fopen($basedirectory."".$_REQUEST['reportname'].'.'.$_REQUEST['reportid'].'_sql','w');

and { was missing

if ($dh = opendir($basedirectory))
should be
if ($dh = opendir($basedirectory)) {

This is working ok Thanks
0
 
LVL 26

Author Closing Comment

by:lenamtl
ID: 33824538
For those that want to apply this modification
check my last answer for little corrections.

Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question