Overview

Packages

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

Classes

  • ArticleForum
  • cGenericDb
  • cGenericDbDriver
  • cGenericDbDriverMysql
  • cItemBaseAbstract
  • cItemCache
  • Item
  • ItemCollection
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the MySQL database driver for the generic db.
  5:  *
  6:  * @package Core
  7:  * @subpackage GenericDB
  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:     /**
 27:      * @see cGenericDbDriver::buildJoinQuery()
 28:      * @param string $destinationTable
 29:      * @param string $destinationClass
 30:      * @param string $destinationPrimaryKey
 31:      * @param string $sourceClass
 32:      * @param string $primaryKey
 33:      * @return array
 34:      */
 35:     public function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) {
 36:         // Build a regular LEFT JOIN
 37:         $field = "$destinationClass.$destinationPrimaryKey";
 38:         $tables = "";
 39:         $join = "LEFT JOIN $destinationTable AS $destinationClass ON " . cSecurity::toString($sourceClass . "." . $primaryKey) . " = " . cSecurity::toString($destinationClass . "." . $primaryKey);
 40:         $where = "";
 41: 
 42:         return array(
 43:             "field" => $field,
 44:             "table" => $tables,
 45:             "join" => $join,
 46:             "where" => $where
 47:         );
 48:     }
 49: 
 50:     /**
 51:      * @see cGenericDbDriver::buildOperator()
 52:      * @param string $sField
 53:      * @param string $sOperator
 54:      * @param string $sRestriction
 55:      * @return string
 56:      */
 57:     public function buildOperator($sField, $sOperator, $sRestriction) {
 58:         $sOperator = cString::toLowerCase($sOperator);
 59: 
 60:         $sWhereStatement = "";
 61: 
 62:         switch ($sOperator) {
 63:             case "matchbool":
 64:                 $sqlStatement = "MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)";
 65:                 $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
 66:                 break;
 67:             case "match":
 68:                 $sqlStatement = "MATCH (%s) AGAINST ('%s')";
 69:                 $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
 70:                 break;
 71:             case "like":
 72:                 $sqlStatement = "%s LIKE '%%%s%%'";
 73:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 74:                 break;
 75:             case "likeleft":
 76:                 $sqlStatement = "%s LIKE '%s%%'";
 77:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 78:                 break;
 79:             case "likeright":
 80:                 $sqlStatement = "%s LIKE '%%%s'";
 81:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 82:                 break;
 83:             case "notlike":
 84:                 $sqlStatement = "%s NOT LIKE '%%%s%%'";
 85:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 86:                 break;
 87:             case "notlikeleft":
 88:                 $sqlStatement = "%s NOT LIKE '%s%%'";
 89:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 90:                 break;
 91:             case "notlikeright":
 92:                 $sqlStatement = "%s NOT LIKE '%%%s'";
 93:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 94:                 break;
 95:             case "fulltext":
 96: 
 97:                 break;
 98:             case "in":
 99:                 if (is_array($sRestriction)) {
100:                     $items = array();
101: 
102:                     foreach ($sRestriction as $key => $sRestrictionItem) {
103:                         $items[] = "'" . $this->_oItemClassInstance->_inFilter($sRestrictionItem) . "'";
104:                     }
105: 
106:                     $sRestriction = implode(", ", $items);
107:                 } else {
108:                     $sRestriction = "'" . $sRestriction . "'";
109:                 }
110: 
111:                 $sWhereStatement = implode(" ", array(
112:                     $sField,
113:                     "IN (",
114:                     $sRestriction,
115:                     ")"
116:                 ));
117:                 break;
118:             default:
119:                 $sRestriction = "'" . $this->_oItemClassInstance->_inFilter($sRestriction) . "'";
120: 
121:                 $sWhereStatement = implode(" ", array(
122:                     $sField,
123:                     $sOperator,
124:                     $sRestriction
125:                 ));
126:         }
127: 
128:         return $sWhereStatement;
129:     }
130: }
131: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0