Click here to Skip to main content
15,887,683 members
Home / Discussions / Database
   

Database

 
GeneralRe: database schema Pin
Kornfeld Eliyahu Peter10-Nov-13 19:35
professionalKornfeld Eliyahu Peter10-Nov-13 19:35 
AnswerRe: database schema Pin
Mycroft Holmes10-Nov-13 21:29
professionalMycroft Holmes10-Nov-13 21:29 
AnswerRe: database schema Pin
jschell11-Nov-13 8:16
jschell11-Nov-13 8:16 
GeneralRe: database schema Pin
PIEBALDconsult11-Nov-13 17:54
mvePIEBALDconsult11-Nov-13 17:54 
AnswerRe: database schema Pin
Shameel12-Nov-13 3:17
professionalShameel12-Nov-13 3:17 
QuestionConditional query (sql) Pin
leone10-Nov-13 7:11
leone10-Nov-13 7:11 
AnswerRe: Conditional query (sql) Pin
Mycroft Holmes10-Nov-13 12:22
professionalMycroft Holmes10-Nov-13 12:22 
QuestionA mixture of PHP PDO and fabricating a query replacing SELECT SQL CALC FOUND ROWS Pin
jkirkerx7-Nov-13 10:12
professionaljkirkerx7-Nov-13 10:12 
I will try my best to describe this, it's the same PHP project from my post below, my next biggest hurdle to jump here.
I'm trying to solve this through SQL, without having to change much of the the PHP Code

I have this line of code, in which it takes a query from the calling class which passes it to this class that contains the line below. Sort of crazy or genius.
$lc_query = '(SELECT SQL_CALC_FOUND_ROWS ' . substr($pc_query, 6) . ') LIMIT ' . (($ln_page - 1) * $ln_pagesize) . ', ' . $ln_pagesize; // This wipes out the parameters!

So I changed the code from using the old mysql handle to the new PDO. I could not find a way to pass an array of parameter tokens to this class, because the token count could be any number of them. The classic trying to bind parameters in a loop failure.

Original way:
Class 1, generate the query, and passes it to class 2
Class 2, calculate page count, then uses the line above to wrap the passed in query and transmit it.

So I did this:
class 1: generates the dynamic query, makes a PDO instance, bind parameters, pass PDO to class 2
class 2: receives the PDO handle, and executes.

So far so good, it works good, stable, but I need the calculations in the Class 2 for page indexing.

I can't figure out how to reintegrate the above statement in class 2 where the page numbers are generated.
I was hoping I would be able to extract the query out of the PDO object, and reconstruct it. Plus I don't think the line above works in PDO.

If you have any thoughts, comments or past experience with this, I'd appreciate it!

Class 1
//PDOClass: Make a Default Connection
$cmd_sp = $PDOClass->QUERY($lc_query);
if ($b_mfgName) $cmd_sp->bindParam(':mfgName', $lc_mfg, PDO::PARAM_STR);                
if ($b_deptID) $cmd_sp->bindParam(':deptID', $pn_dept_id, PDO::PARAM_INT);
if ($b_partnerID) $cmd_sp->bindParam(':partnerID', $go_sitedict['partner_id'], PDO::PARAM_INT);

$SPClass = new SPClass(
  $cmd_sp, 
  $cmd_sp_mfg, 
  FALSE, 
  '', 
  $ll_debug
);

Class 2:
// So how to we wrap this around the query that we already sent to PDO?
$lc_query = '(SELECT SQL_CALC_FOUND_ROWS ' . substr($pc_query, 6) . ') LIMIT ' . (($ln_page - 1) * $ln_pagesize) . ', ' . $ln_pagesize; // This wipes out the parameters!
            
try {           
     // PDOClass: Execute the PDO that was passed in
     $cmd_showProduct->execute();
                
}

QuestionSQL Query, Unknown column 'p.prod_id' in 'on clause' Pin
jkirkerx7-Nov-13 6:19
professionaljkirkerx7-Nov-13 6:19 
AnswerRe: SQL Query, Unknown column 'p.prod_id' in 'on clause' Pin
Tim Carmichael7-Nov-13 7:47
Tim Carmichael7-Nov-13 7:47 
GeneralRe: SQL Query, Unknown column 'p.prod_id' in 'on clause' Pin
jkirkerx7-Nov-13 8:33
professionaljkirkerx7-Nov-13 8:33 
AnswerRe: SQL Query, Unknown column 'p.prod_id' in 'on clause' Pin
Jörgen Andersson7-Nov-13 8:33
professionalJörgen Andersson7-Nov-13 8:33 
GeneralRe: SQL Query, Unknown column 'p.prod_id' in 'on clause' Pin
jkirkerx7-Nov-13 8:49
professionaljkirkerx7-Nov-13 8:49 
GeneralRe: SQL Query, Unknown column 'p.prod_id' in 'on clause' Pin
Jörgen Andersson7-Nov-13 9:15
professionalJörgen Andersson7-Nov-13 9:15 
GeneralIt's pretty close, needs some more adjustments. Pin
jkirkerx7-Nov-13 13:57
professionaljkirkerx7-Nov-13 13:57 
Questionaccess procedure Pin
shabha1106-Nov-13 21:26
shabha1106-Nov-13 21:26 
AnswerRe: access procedure Pin
Mycroft Holmes6-Nov-13 21:52
professionalMycroft Holmes6-Nov-13 21:52 
QuestionOracle 10g connectivity issue with .net 2.0 website hosted on win 2008 server Pin
abhi17_66-Nov-13 4:19
abhi17_66-Nov-13 4:19 
AnswerRe: Oracle 10g connectivity issue with .net 2.0 website hosted on win 2008 server Pin
jschell6-Nov-13 8:08
jschell6-Nov-13 8:08 
GeneralRe: Oracle 10g connectivity issue with .net 2.0 website hosted on win 2008 server Pin
abhi17_66-Nov-13 15:45
abhi17_66-Nov-13 15:45 
GeneralRe: Oracle 10g connectivity issue with .net 2.0 website hosted on win 2008 server Pin
jschell7-Nov-13 9:16
jschell7-Nov-13 9:16 
QuestionHow to create directory in SQL with Space Pin
Samarjeet Singh@india6-Nov-13 0:47
Samarjeet Singh@india6-Nov-13 0:47 
AnswerRe: How to create directory in SQL with Space Pin
Chris Quinn6-Nov-13 1:08
Chris Quinn6-Nov-13 1:08 
GeneralRe: How to create directory in SQL with Space Pin
Samarjeet Singh@india6-Nov-13 1:22
Samarjeet Singh@india6-Nov-13 1:22 
QuestionRe: How to create directory in SQL with Space Pin
thatraja6-Nov-13 2:06
professionalthatraja6-Nov-13 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.