| @@ 752-776 (lines=25) @@ | ||
| 749 | * @return string |
|
| 750 | * @see GetSql() |
|
| 751 | */ |
|
| 752 | public function GetSqlPrepare($ar_config = array()) { |
|
| 753 | $sql = $this->GetSql($ar_config); |
|
| 754 | /* Old treatment |
|
| 755 | // Notice: The simple treatment here may cause wrong when ? and : are original sql needed |
|
| 756 | $sql = str_replace("'?'", '?', $sql); |
|
| 757 | // Notice: For oracle, not tested yet. |
|
| 758 | $sql = preg_replace('/\'(:[^\']+)\'/', '$1', $sql); |
|
| 759 | */ |
|
| 760 | ||
| 761 | // Better treatment |
|
| 762 | // Remove duplicate ' in sql add by SqlGenerator, |
|
| 763 | // Execute after Prepare will auto recoginize variant type and quote, |
|
| 764 | // but notice, it's VAR TYPE and NOT DB COLUMN TYPE. |
|
| 765 | // replaceQuote: The string used to escape quotes. Eg. double single-quotes for |
|
| 766 | // Microsoft SQL, and backslash-quote for MySQL. Used by qstr. |
|
| 767 | if ("''" == $this->oDb->replaceQuote) |
|
| 768 | $s_quote = "'"; |
|
| 769 | else |
|
| 770 | $s_quote = $this->oDb->replaceQuote; |
|
| 771 | $sql = preg_replace( |
|
| 772 | "/ {$s_quote}([\?\:\w\-_]+){$s_quote}([, ])/i", |
|
| 773 | " $1$2", $sql); |
|
| 774 | ||
| 775 | return $sql; |
|
| 776 | } // end of function GetSqlPrepare |
|
| 777 | ||
| 778 | ||
| 779 | /** |
|
| @@ 464-485 (lines=22) @@ | ||
| 461 | * @param array $param |
|
| 462 | * @return string |
|
| 463 | */ |
|
| 464 | public function getPrepared($param = []) |
|
| 465 | { |
|
| 466 | $sql = $this->get($param); |
|
| 467 | ||
| 468 | // @codeCoverageIgnoreStart |
|
| 469 | // Remove duplicate ' in sql add by SqlGenerator, |
|
| 470 | if ("''" == $this->db->replaceQuote) { |
|
| 471 | $quote = "'"; |
|
| 472 | } else { |
|
| 473 | $quote = $this->db->replaceQuote; |
|
| 474 | } |
|
| 475 | // @codeCoverageIgnoreEnd |
|
| 476 | ||
| 477 | // Remove quote |
|
| 478 | $sql = preg_replace( |
|
| 479 | "/([\s,\(]){$quote}([\?\:\w\-_]+){$quote}([\s,\)])/i", |
|
| 480 | "$1$2$3", |
|
| 481 | $sql |
|
| 482 | ); |
|
| 483 | ||
| 484 | return $sql; |
|
| 485 | } |
|
| 486 | ||
| 487 | ||
| 488 | /** |
|