Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • ArticleForum
  • cApiShortUrl
  • cGenericDb
  • cGenericDbDriver
  • cGenericDbDriverMysql
  • cItemBaseAbstract
  • cItemCache
  • Item
  • ItemCollection
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the MySQL database driver for the generic db.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       GenericDB
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Bjoern Behrens
 10:  * @copyright        four for business AG <www.4fb.de>
 11:  * @license          http://www.contenido.org/license/LIZENZ.txt
 12:  * @link             http://www.4fb.de
 13:  * @link             http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * MySQL database driver
 20:  *
 21:  * @package    Core
 22:  * @subpackage GenericDB
 23:  */
 24: class cGenericDbDriverMysql extends cGenericDbDriver {
 25: 
 26:     public function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) {
 27:         // Build a regular LEFT JOIN
 28:         $field = "$destinationClass.$destinationPrimaryKey";
 29:         $tables = "";
 30:         $join = "LEFT JOIN $destinationTable AS $destinationClass ON " . cSecurity::toString($sourceClass . "." . $primaryKey) . " = " . cSecurity::toString($destinationClass . "." . $primaryKey);
 31:         $where = "";
 32: 
 33:         return array(
 34:             "field" => $field,
 35:             "table" => $tables,
 36:             "join" => $join,
 37:             "where" => $where
 38:         );
 39:     }
 40: 
 41:     public function buildOperator($sField, $sOperator, $sRestriction) {
 42:         $sOperator = strtolower($sOperator);
 43: 
 44:         $sWhereStatement = "";
 45: 
 46:         switch ($sOperator) {
 47:             case "matchbool":
 48:                 $sqlStatement = "MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)";
 49:                 $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
 50:                 break;
 51:             case "match":
 52:                 $sqlStatement = "MATCH (%s) AGAINST ('%s')";
 53:                 $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
 54:                 break;
 55:             case "like":
 56:                 $sqlStatement = "%s LIKE '%%%s%%'";
 57:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 58:                 break;
 59:             case "likeleft":
 60:                 $sqlStatement = "%s LIKE '%s%%'";
 61:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 62:                 break;
 63:             case "likeright":
 64:                 $sqlStatement = "%s LIKE '%%%s'";
 65:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 66:                 break;
 67:             case "notlike":
 68:                 $sqlStatement = "%s NOT LIKE '%%%s%%'";
 69:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 70:                 break;
 71:             case "notlikeleft":
 72:                 $sqlStatement = "%s NOT LIKE '%s%%'";
 73:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 74:                 break;
 75:             case "notlikeright":
 76:                 $sqlStatement = "%s NOT LIKE '%%%s'";
 77:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 78:                 break;
 79:             case "fulltext":
 80: 
 81:                 break;
 82:             case "in":
 83:                 if (is_array($sRestriction)) {
 84:                     $items = array();
 85: 
 86:                     foreach ($sRestriction as $key => $sRestrictionItem) {
 87:                         $items[] = "'" . $this->_oItemClassInstance->_inFilter($sRestrictionItem) . "'";
 88:                     }
 89: 
 90:                     $sRestriction = implode(", ", $items);
 91:                 } else {
 92:                     $sRestriction = "'" . $sRestriction . "'";
 93:                 }
 94: 
 95:                 $sWhereStatement = implode(" ", array(
 96:                     $sField,
 97:                     "IN (",
 98:                     $sRestriction,
 99:                     ")"
100:                 ));
101:                 break;
102:             default:
103:                 $sRestriction = "'" . $this->_oItemClassInstance->_inFilter($sRestriction) . "'";
104: 
105:                 $sWhereStatement = implode(" ", array(
106:                     $sField,
107:                     $sOperator,
108:                     $sRestriction
109:                 ));
110:         }
111: 
112:         return $sWhereStatement;
113:     }
114: 
115: }
116: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0