@@ -32,33 +32,33 @@ discard block |
||
| 32 | 32 | const SAMBA4 = 2; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * @var array $namingContext holds the supported namingcontexts |
|
| 36 | - */ |
|
| 35 | + * @var array $namingContext holds the supported namingcontexts |
|
| 36 | + */ |
|
| 37 | 37 | var $namingContext = array(); |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * @var string $version holds the LDAP server version |
|
| 41 | - */ |
|
| 40 | + * @var string $version holds the LDAP server version |
|
| 41 | + */ |
|
| 42 | 42 | var $version = 2; |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * @var integer $serverType holds the type of LDAP server(OpenLDAP, ADS, NDS, ...) |
|
| 46 | - */ |
|
| 45 | + * @var integer $serverType holds the type of LDAP server(OpenLDAP, ADS, NDS, ...) |
|
| 46 | + */ |
|
| 47 | 47 | var $serverType = 0; |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * @var string $_subSchemaEntry the subschema entry DN |
|
| 51 | - */ |
|
| 50 | + * @var string $_subSchemaEntry the subschema entry DN |
|
| 51 | + */ |
|
| 52 | 52 | var $subSchemaEntry = ''; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * @var array $supportedObjectClasses the supported objectclasses |
|
| 56 | - */ |
|
| 55 | + * @var array $supportedObjectClasses the supported objectclasses |
|
| 56 | + */ |
|
| 57 | 57 | var $supportedObjectClasses = array(); |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * @var array $supportedOIDs the supported OIDs |
|
| 61 | - */ |
|
| 60 | + * @var array $supportedOIDs the supported OIDs |
|
| 61 | + */ |
|
| 62 | 62 | var $supportedOIDs = array(); |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -79,50 +79,50 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | - * gets the version |
|
| 83 | - * |
|
| 84 | - * @return integer the supported ldap version |
|
| 85 | - */ |
|
| 82 | + * gets the version |
|
| 83 | + * |
|
| 84 | + * @return integer the supported ldap version |
|
| 85 | + */ |
|
| 86 | 86 | function getVersion() |
| 87 | 87 | { |
| 88 | 88 | return $this->version; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * sets the namingcontexts |
|
| 93 | - * |
|
| 94 | - * @param array $_namingContext the supported namingcontexts |
|
| 95 | - */ |
|
| 92 | + * sets the namingcontexts |
|
| 93 | + * |
|
| 94 | + * @param array $_namingContext the supported namingcontexts |
|
| 95 | + */ |
|
| 96 | 96 | function setNamingContexts($_namingContext) |
| 97 | 97 | { |
| 98 | 98 | $this->namingContext = $_namingContext; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | - * sets the type of the ldap server(OpenLDAP, ADS, NDS, ...) |
|
| 103 | - * |
|
| 104 | - * @param integer $_serverType the type of ldap server |
|
| 105 | - */ |
|
| 102 | + * sets the type of the ldap server(OpenLDAP, ADS, NDS, ...) |
|
| 103 | + * |
|
| 104 | + * @param integer $_serverType the type of ldap server |
|
| 105 | + */ |
|
| 106 | 106 | function setServerType($_serverType) |
| 107 | 107 | { |
| 108 | 108 | $this->serverType = $_serverType; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | - * sets the DN for the subschema entry |
|
| 113 | - * |
|
| 114 | - * @param string $_subSchemaEntry the subschema entry DN |
|
| 115 | - */ |
|
| 112 | + * sets the DN for the subschema entry |
|
| 113 | + * |
|
| 114 | + * @param string $_subSchemaEntry the subschema entry DN |
|
| 115 | + */ |
|
| 116 | 116 | function setSubSchemaEntry($_subSchemaEntry) |
| 117 | 117 | { |
| 118 | 118 | $this->subSchemaEntry = $_subSchemaEntry; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * sets the supported objectclasses |
|
| 123 | - * |
|
| 124 | - * @param array $_supportedObjectClasses the supported objectclasses |
|
| 125 | - */ |
|
| 122 | + * sets the supported objectclasses |
|
| 123 | + * |
|
| 124 | + * @param array $_supportedObjectClasses the supported objectclasses |
|
| 125 | + */ |
|
| 126 | 126 | function setSupportedObjectClasses($_supportedObjectClasses) |
| 127 | 127 | { |
| 128 | 128 | $this->supportedOIDs = $_supportedObjectClasses; |
@@ -130,20 +130,20 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | - * sets the version |
|
| 134 | - * |
|
| 135 | - * @param integer $_version the supported ldap version |
|
| 136 | - */ |
|
| 133 | + * sets the version |
|
| 134 | + * |
|
| 135 | + * @param integer $_version the supported ldap version |
|
| 136 | + */ |
|
| 137 | 137 | function setVersion($_version) |
| 138 | 138 | { |
| 139 | 139 | $this->version = $_version; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | - * checks for supported objectclasses |
|
| 144 | - * |
|
| 145 | - * @return bool returns true if the ldap server supports this objectclass |
|
| 146 | - */ |
|
| 143 | + * checks for supported objectclasses |
|
| 144 | + * |
|
| 145 | + * @return bool returns true if the ldap server supports this objectclass |
|
| 146 | + */ |
|
| 147 | 147 | function supportsObjectClass($_objectClass) |
| 148 | 148 | { |
| 149 | 149 | if($this->supportedObjectClasses[strtolower($_objectClass)]) |
@@ -210,12 +210,12 @@ |
||
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | - * saves custom field data |
|
| 214 | - * |
|
| 215 | - * @param array $data data to save (cf's have to be prefixed with self::CF_PREFIX = #) |
|
| 216 | - * @param array $extra_cols =array() extra-data to be saved |
|
| 217 | - * @return bool false on success, errornumber on failure |
|
| 218 | - */ |
|
| 213 | + * saves custom field data |
|
| 214 | + * |
|
| 215 | + * @param array $data data to save (cf's have to be prefixed with self::CF_PREFIX = #) |
|
| 216 | + * @param array $extra_cols =array() extra-data to be saved |
|
| 217 | + * @return bool false on success, errornumber on failure |
|
| 218 | + */ |
|
| 219 | 219 | function save_customfields($data, array $extra_cols=array()) |
| 220 | 220 | { |
| 221 | 221 | foreach (array_keys((array)$this->customfields) as $name) |
@@ -242,13 +242,13 @@ |
||
| 242 | 242 | if ($ret === false && ($err = json_last_error())) |
| 243 | 243 | { |
| 244 | 244 | static $json_err2str = array( |
| 245 | - JSON_ERROR_NONE => 'No errors', |
|
| 246 | - JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', |
|
| 247 | - JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', |
|
| 248 | - JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', |
|
| 249 | - JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', |
|
| 250 | - JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', |
|
| 251 | - ); |
|
| 245 | + JSON_ERROR_NONE => 'No errors', |
|
| 246 | + JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', |
|
| 247 | + JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', |
|
| 248 | + JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', |
|
| 249 | + JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', |
|
| 250 | + JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', |
|
| 251 | + ); |
|
| 252 | 252 | error_log(__METHOD__.'('.array2string($var).') json_last_error()='.$err.'='.$json_err2str[$err]); |
| 253 | 253 | |
| 254 | 254 | if (($var = self::fix_content($var))) |
@@ -249,12 +249,12 @@ |
||
| 249 | 249 | |
| 250 | 250 | $this->component = Horde_Icalendar::newComponent($type, $this); |
| 251 | 251 | //error_log(__METHOD__."() this->component = Horde_Icalendar::newComponent('$type', \$this) = ".array2string($this->component)); |
| 252 | - if ($this->component === false) |
|
| 253 | - { |
|
| 254 | - error_log(__METHOD__."() Horde_Icalendar::newComponent('$type', \$this) returned FALSE"); |
|
| 255 | - return; |
|
| 256 | - //return PEAR::raiseError("Unable to create object for type $type"); |
|
| 257 | - } |
|
| 252 | + if ($this->component === false) |
|
| 253 | + { |
|
| 254 | + error_log(__METHOD__."() Horde_Icalendar::newComponent('$type', \$this) returned FALSE"); |
|
| 255 | + return; |
|
| 256 | + //return PEAR::raiseError("Unable to create object for type $type"); |
|
| 257 | + } |
|
| 258 | 258 | if ($this->charset && $this->charset != 'utf-8') |
| 259 | 259 | { |
| 260 | 260 | $data = Api\Translation::convert($data, $this->charset, 'utf-8'); |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | * Log mails to log file specified in $GLOBALS['egw_info']['server']['log_mail'] |
| 482 | 482 | * or regular error_log for true (can be set either in DB or header.inc.php). |
| 483 | 483 | * |
| 484 | - * @param Horde_Mail_Transport $transport =null using transport from mail-account |
|
| 484 | + * @param Horde_Mail_Transport $transport =null using transport from mail-account |
|
| 485 | 485 | * specified in construct, or default one, if not specified |
| 486 | - * @param boolean $resend =true allways true in EGroupware! |
|
| 487 | - * @param boolean $flowed =null send message in flowed text format, |
|
| 486 | + * @param boolean $resend =true allways true in EGroupware! |
|
| 487 | + * @param boolean $flowed =null send message in flowed text format, |
|
| 488 | 488 | * default null used flowed by default for everything but multipart/encrypted, |
| 489 | 489 | * unless disabled in site configuration ("disable_rfc3676_flowed") |
| 490 | 490 | * |
@@ -642,15 +642,15 @@ discard block |
||
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | - * Get the raw email data sent by this object. |
|
| 646 | - * |
|
| 645 | + * Get the raw email data sent by this object. |
|
| 646 | + * |
|
| 647 | 647 | * Reimplement to be able to call it for saveAsDraft by calling |
| 648 | 648 | * $this->send(new Horde_Mail_Transport_Null()), |
| 649 | 649 | * if no base-part is set, because send is not called before. |
| 650 | 650 | * |
| 651 | - * @param boolean $stream If true, return a stream resource, otherwise |
|
| 652 | - * @return stream|string The raw email data. |
|
| 653 | - */ |
|
| 651 | + * @param boolean $stream If true, return a stream resource, otherwise |
|
| 652 | + * @return stream|string The raw email data. |
|
| 653 | + */ |
|
| 654 | 654 | function getRaw($stream=true) |
| 655 | 655 | { |
| 656 | 656 | try { |
@@ -663,20 +663,20 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | // code copied from Horde_Mime_Mail::getRaw(), as there is no way to inject charset in |
| 665 | 665 | // _headers->toString(), which is required to encode headers containing non-ascii chars correct |
| 666 | - if ($stream) { |
|
| 667 | - $hdr = new Horde_Stream(); |
|
| 668 | - $hdr->add($this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)), true); |
|
| 669 | - return Horde_Stream_Wrapper_Combine::getStream( |
|
| 670 | - array($hdr->stream, |
|
| 671 | - $this->getBasePart()->toString( |
|
| 672 | - array('stream' => true, 'canonical' => true, 'encode' => Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY)) |
|
| 673 | - ) |
|
| 674 | - ); |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - return $this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)) . |
|
| 666 | + if ($stream) { |
|
| 667 | + $hdr = new Horde_Stream(); |
|
| 668 | + $hdr->add($this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)), true); |
|
| 669 | + return Horde_Stream_Wrapper_Combine::getStream( |
|
| 670 | + array($hdr->stream, |
|
| 671 | + $this->getBasePart()->toString( |
|
| 672 | + array('stream' => true, 'canonical' => true, 'encode' => Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY)) |
|
| 673 | + ) |
|
| 674 | + ); |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + return $this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)) . |
|
| 678 | 678 | $this->getBasePart()->toString(array('canonical' => true)); |
| 679 | - } |
|
| 679 | + } |
|
| 680 | 680 | |
| 681 | 681 | /** |
| 682 | 682 | * Convert charset of text-parts of message to utf-8 |
@@ -738,12 +738,12 @@ discard block |
||
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
| 741 | - * provides centralization and compatibility to locate the lang files |
|
| 742 | - * |
|
| 743 | - * @param string $app application name |
|
| 744 | - * @param string $lang language code |
|
| 745 | - * @return the full path of the filename for the requested app and language |
|
| 746 | - */ |
|
| 741 | + * provides centralization and compatibility to locate the lang files |
|
| 742 | + * |
|
| 743 | + * @param string $app application name |
|
| 744 | + * @param string $lang language code |
|
| 745 | + * @return the full path of the filename for the requested app and language |
|
| 746 | + */ |
|
| 747 | 747 | static function get_lang_file($app,$lang) |
| 748 | 748 | { |
| 749 | 749 | if ($app == 'common') $app = 'phpgwapi'; |
@@ -1074,13 +1074,13 @@ discard block |
||
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | /** |
| 1077 | - * detect_encoding - try to detect the encoding |
|
| 1078 | - * only to be used if the string in question has no structure that determines his encoding |
|
| 1079 | - * |
|
| 1080 | - * @param string - to be evaluated |
|
| 1081 | - * @param string $verify =null encoding to verify, get checked first and have a match for only ascii or no detection available |
|
| 1082 | - * @return string - encoding |
|
| 1083 | - */ |
|
| 1077 | + * detect_encoding - try to detect the encoding |
|
| 1078 | + * only to be used if the string in question has no structure that determines his encoding |
|
| 1079 | + * |
|
| 1080 | + * @param string - to be evaluated |
|
| 1081 | + * @param string $verify =null encoding to verify, get checked first and have a match for only ascii or no detection available |
|
| 1082 | + * @return string - encoding |
|
| 1083 | + */ |
|
| 1084 | 1084 | static function detect_encoding($string, $verify=null) |
| 1085 | 1085 | { |
| 1086 | 1086 | if (function_exists('iconv')) |
@@ -80,60 +80,60 @@ discard block |
||
| 80 | 80 | const MCRYPT_MODE = MCRYPT_MODE_ECB; |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * current user login (account_lid@domain) |
|
| 84 | - * |
|
| 85 | - * @var string |
|
| 86 | - */ |
|
| 83 | + * current user login (account_lid@domain) |
|
| 84 | + * |
|
| 85 | + * @var string |
|
| 86 | + */ |
|
| 87 | 87 | var $login; |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * current user password |
|
| 91 | - * |
|
| 92 | - * @var string |
|
| 93 | - */ |
|
| 90 | + * current user password |
|
| 91 | + * |
|
| 92 | + * @var string |
|
| 93 | + */ |
|
| 94 | 94 | var $passwd; |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | - * current user db/ldap account id |
|
| 98 | - * |
|
| 99 | - * @var int |
|
| 100 | - */ |
|
| 97 | + * current user db/ldap account id |
|
| 98 | + * |
|
| 99 | + * @var int |
|
| 100 | + */ |
|
| 101 | 101 | var $account_id; |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | - * current user account login id (without the eGW-domain/-instance part |
|
| 105 | - * |
|
| 106 | - * @var string |
|
| 107 | - */ |
|
| 104 | + * current user account login id (without the eGW-domain/-instance part |
|
| 105 | + * |
|
| 106 | + * @var string |
|
| 107 | + */ |
|
| 108 | 108 | var $account_lid; |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | - * domain for current user |
|
| 112 | - * |
|
| 113 | - * @var string |
|
| 114 | - */ |
|
| 111 | + * domain for current user |
|
| 112 | + * |
|
| 113 | + * @var string |
|
| 114 | + */ |
|
| 115 | 115 | var $account_domain; |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | - * type flag, A - anonymous session, N - None, normal session |
|
| 119 | - * |
|
| 120 | - * @var string |
|
| 121 | - */ |
|
| 118 | + * type flag, A - anonymous session, N - None, normal session |
|
| 119 | + * |
|
| 120 | + * @var string |
|
| 121 | + */ |
|
| 122 | 122 | var $session_flags; |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | - * current user session id |
|
| 126 | - * |
|
| 127 | - * @var string |
|
| 128 | - */ |
|
| 125 | + * current user session id |
|
| 126 | + * |
|
| 127 | + * @var string |
|
| 128 | + */ |
|
| 129 | 129 | var $sessionid; |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * an other session specific id (md5 from a random string), |
|
| 133 | - * used together with the sessionid for xmlrpc basic auth and the encryption of session-data (if that's enabled) |
|
| 134 | - * |
|
| 135 | - * @var string |
|
| 136 | - */ |
|
| 132 | + * an other session specific id (md5 from a random string), |
|
| 133 | + * used together with the sessionid for xmlrpc basic auth and the encryption of session-data (if that's enabled) |
|
| 134 | + * |
|
| 135 | + * @var string |
|
| 136 | + */ |
|
| 137 | 137 | var $kp3; |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -144,17 +144,17 @@ discard block |
||
| 144 | 144 | var $sessionid_access_log; |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | - * name of XML-RPC/SOAP method called |
|
| 148 | - * |
|
| 149 | - * @var string |
|
| 150 | - */ |
|
| 147 | + * name of XML-RPC/SOAP method called |
|
| 148 | + * |
|
| 149 | + * @var string |
|
| 150 | + */ |
|
| 151 | 151 | var $xmlrpc_method_called; |
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | - * Array with the name of the system domains |
|
| 155 | - * |
|
| 156 | - * @var array |
|
| 157 | - */ |
|
| 154 | + * Array with the name of the system domains |
|
| 155 | + * |
|
| 156 | + * @var array |
|
| 157 | + */ |
|
| 158 | 158 | private $egw_domains; |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | // set session_timeout from global php.ini and default to 14400=4h, if not set |
| 250 | 250 | if (!($GLOBALS['egw_info']['server']['sessions_timeout'] = ini_get('session.gc_maxlifetime'))) |
| 251 | - { |
|
| 252 | - ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400); |
|
| 253 | - } |
|
| 251 | + { |
|
| 252 | + ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400); |
|
| 253 | + } |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -661,14 +661,14 @@ discard block |
||
| 661 | 661 | const ACCESS_LOG_TABLE = 'egw_access_log'; |
| 662 | 662 | |
| 663 | 663 | /** |
| 664 | - * Write or update (for logout) the access_log |
|
| 665 | - * |
|
| 666 | - * @param string|int $sessionid nummeric or PHP session id or 0 for unsuccessful logins |
|
| 667 | - * @param string $login ='' account_lid (evtl. with domain) or '' for setting the logout-time |
|
| 668 | - * @param string $user_ip ='' ip to log |
|
| 669 | - * @param int $account_id =0 numerical account_id |
|
| 670 | - * @return int $sessionid primary key of egw_access_log for login, null otherwise |
|
| 671 | - */ |
|
| 664 | + * Write or update (for logout) the access_log |
|
| 665 | + * |
|
| 666 | + * @param string|int $sessionid nummeric or PHP session id or 0 for unsuccessful logins |
|
| 667 | + * @param string $login ='' account_lid (evtl. with domain) or '' for setting the logout-time |
|
| 668 | + * @param string $user_ip ='' ip to log |
|
| 669 | + * @param int $account_id =0 numerical account_id |
|
| 670 | + * @return int $sessionid primary key of egw_access_log for login, null otherwise |
|
| 671 | + */ |
|
| 672 | 672 | private function log_access($sessionid,$login='',$user_ip='',$account_id=0) |
| 673 | 673 | { |
| 674 | 674 | $now = time(); |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | /** |
| 718 | 718 | * Protect against brute force attacks, block login if too many unsuccessful login attmepts |
| 719 | - * |
|
| 719 | + * |
|
| 720 | 720 | * @param string $login account_lid (evtl. with domain) |
| 721 | 721 | * @param string $ip ip of the user |
| 722 | 722 | * @returns bool login blocked? |
@@ -1044,13 +1044,13 @@ |
||
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | /** |
| 1047 | - * Get the color of a category |
|
| 1048 | - * |
|
| 1049 | - * For multiple cats, the first with a color is used |
|
| 1050 | - * |
|
| 1051 | - * @param int|string $_cats multiple comma-separated cat_id's |
|
| 1052 | - * @return string |
|
| 1053 | - */ |
|
| 1047 | + * Get the color of a category |
|
| 1048 | + * |
|
| 1049 | + * For multiple cats, the first with a color is used |
|
| 1050 | + * |
|
| 1051 | + * @param int|string $_cats multiple comma-separated cat_id's |
|
| 1052 | + * @return string |
|
| 1053 | + */ |
|
| 1054 | 1054 | static function cats2color($_cats) |
| 1055 | 1055 | { |
| 1056 | 1056 | static $cat2color = array(); |
@@ -67,43 +67,43 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | const FETCH_BOTH = ADODB_FETCH_BOTH; |
| 69 | 69 | /** |
| 70 | - * @var string $type translated database type: mysqlt+mysqli ==> mysql, same for odbc-types |
|
| 71 | - */ |
|
| 70 | + * @var string $type translated database type: mysqlt+mysqli ==> mysql, same for odbc-types |
|
| 71 | + */ |
|
| 72 | 72 | var $Type = ''; |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | - * @var string $type database type as defined in the header.inc.php, eg. mysqlt |
|
| 76 | - */ |
|
| 75 | + * @var string $type database type as defined in the header.inc.php, eg. mysqlt |
|
| 76 | + */ |
|
| 77 | 77 | var $setupType = ''; |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * @var string $Host database host to connect to |
|
| 81 | - */ |
|
| 80 | + * @var string $Host database host to connect to |
|
| 81 | + */ |
|
| 82 | 82 | var $Host = ''; |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * @var string $Port port number of database to connect to |
|
| 86 | - */ |
|
| 85 | + * @var string $Port port number of database to connect to |
|
| 86 | + */ |
|
| 87 | 87 | var $Port = ''; |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * @var string $Database name of database to use |
|
| 91 | - */ |
|
| 90 | + * @var string $Database name of database to use |
|
| 91 | + */ |
|
| 92 | 92 | var $Database = ''; |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * @var string $User name of database user |
|
| 96 | - */ |
|
| 95 | + * @var string $User name of database user |
|
| 96 | + */ |
|
| 97 | 97 | var $User = ''; |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | - * @var string $Password password for database user |
|
| 101 | - */ |
|
| 100 | + * @var string $Password password for database user |
|
| 101 | + */ |
|
| 102 | 102 | var $Password = ''; |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | - * @var int $Debug enable debuging - 0 no, 1 yes |
|
| 106 | - */ |
|
| 105 | + * @var int $Debug enable debuging - 0 no, 1 yes |
|
| 106 | + */ |
|
| 107 | 107 | var $Debug = 0; |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,23 +114,23 @@ discard block |
||
| 114 | 114 | var $log_updates = false; |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | - * @var array $Record current record |
|
| 118 | - */ |
|
| 117 | + * @var array $Record current record |
|
| 118 | + */ |
|
| 119 | 119 | var $Record = array(); |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * @var int row number for current record |
|
| 123 | - */ |
|
| 122 | + * @var int row number for current record |
|
| 123 | + */ |
|
| 124 | 124 | var $Row; |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * @var int $Errno internal rdms error number for last error |
|
| 128 | - */ |
|
| 127 | + * @var int $Errno internal rdms error number for last error |
|
| 128 | + */ |
|
| 129 | 129 | var $Errno = 0; |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * @var string descriptive text from last error |
|
| 133 | - */ |
|
| 132 | + * @var string descriptive text from last error |
|
| 133 | + */ |
|
| 134 | 134 | var $Error = ''; |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
| 273 | - * @param string $query query to be executed (optional) |
|
| 274 | - */ |
|
| 273 | + * @param string $query query to be executed (optional) |
|
| 274 | + */ |
|
| 275 | 275 | |
| 276 | 276 | function db($query = '') |
| 277 | 277 | { |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | - * @return int current connection id |
|
| 283 | - */ |
|
| 282 | + * @return int current connection id |
|
| 283 | + */ |
|
| 284 | 284 | function link_id() |
| 285 | 285 | { |
| 286 | 286 | return $this->Link_ID; |
@@ -652,8 +652,8 @@ discard block |
||
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
| 655 | - * Close a connection to a database |
|
| 656 | - */ |
|
| 655 | + * Close a connection to a database |
|
| 656 | + */ |
|
| 657 | 657 | function disconnect() |
| 658 | 658 | { |
| 659 | 659 | if (!$this->privat_Link_ID) |
@@ -667,11 +667,11 @@ discard block |
||
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /** |
| 670 | - * Convert a unix timestamp to a rdms specific timestamp |
|
| 671 | - * |
|
| 672 | - * @param int unix timestamp |
|
| 673 | - * @return string rdms specific timestamp |
|
| 674 | - */ |
|
| 670 | + * Convert a unix timestamp to a rdms specific timestamp |
|
| 671 | + * |
|
| 672 | + * @param int unix timestamp |
|
| 673 | + * @return string rdms specific timestamp |
|
| 674 | + */ |
|
| 675 | 675 | function to_timestamp($epoch) |
| 676 | 676 | { |
| 677 | 677 | if (!$this->Link_ID && !$this->connect()) |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** |
| 686 | - * Convert a rdms specific timestamp to a unix timestamp |
|
| 687 | - * |
|
| 688 | - * @param string rdms specific timestamp |
|
| 689 | - * @return int unix timestamp |
|
| 690 | - */ |
|
| 686 | + * Convert a rdms specific timestamp to a unix timestamp |
|
| 687 | + * |
|
| 688 | + * @param string rdms specific timestamp |
|
| 689 | + * @return int unix timestamp |
|
| 690 | + */ |
|
| 691 | 691 | function from_timestamp($timestamp) |
| 692 | 692 | { |
| 693 | 693 | if (!$this->Link_ID && !$this->connect()) |
@@ -709,19 +709,19 @@ discard block |
||
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | /** |
| 712 | - * Execute a query |
|
| 713 | - * |
|
| 714 | - * @param string $Query_String the query to be executed |
|
| 715 | - * @param int $line the line method was called from - use __LINE__ |
|
| 716 | - * @param string $file the file method was called from - use __FILE__ |
|
| 717 | - * @param int $offset row to start from, default 0 |
|
| 718 | - * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] |
|
| 719 | - * @param array|boolean $inputarr array for binding variables to parameters or false (default) |
|
| 720 | - * @param int $fetchmode =self::FETCH_BOTH self::FETCH_BOTH (default), self::FETCH_ASSOC or self::FETCH_NUM |
|
| 721 | - * @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!) |
|
| 722 | - * @return ADORecordSet or false, if the query fails |
|
| 723 | - * @throws Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code |
|
| 724 | - */ |
|
| 712 | + * Execute a query |
|
| 713 | + * |
|
| 714 | + * @param string $Query_String the query to be executed |
|
| 715 | + * @param int $line the line method was called from - use __LINE__ |
|
| 716 | + * @param string $file the file method was called from - use __FILE__ |
|
| 717 | + * @param int $offset row to start from, default 0 |
|
| 718 | + * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] |
|
| 719 | + * @param array|boolean $inputarr array for binding variables to parameters or false (default) |
|
| 720 | + * @param int $fetchmode =self::FETCH_BOTH self::FETCH_BOTH (default), self::FETCH_ASSOC or self::FETCH_NUM |
|
| 721 | + * @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!) |
|
| 722 | + * @return ADORecordSet or false, if the query fails |
|
| 723 | + * @throws Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code |
|
| 724 | + */ |
|
| 725 | 725 | function query($Query_String, $line = '', $file = '', $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=self::FETCH_BOTH, $reconnect=true) |
| 726 | 726 | { |
| 727 | 727 | unset($line, $file); // not used anymore |
@@ -786,26 +786,26 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | /** |
| 789 | - * Execute a query with limited result set |
|
| 790 | - * |
|
| 791 | - * @param string $Query_String the query to be executed |
|
| 792 | - * @param int $offset row to start from, default 0 |
|
| 793 | - * @param int $line the line method was called from - use __LINE__ |
|
| 794 | - * @param string $file the file method was called from - use __FILE__ |
|
| 795 | - * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] |
|
| 796 | - * @param array|boolean $inputarr array for binding variables to parameters or false (default) |
|
| 797 | - * @return ADORecordSet or false, if the query fails |
|
| 798 | - */ |
|
| 789 | + * Execute a query with limited result set |
|
| 790 | + * |
|
| 791 | + * @param string $Query_String the query to be executed |
|
| 792 | + * @param int $offset row to start from, default 0 |
|
| 793 | + * @param int $line the line method was called from - use __LINE__ |
|
| 794 | + * @param string $file the file method was called from - use __FILE__ |
|
| 795 | + * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] |
|
| 796 | + * @param array|boolean $inputarr array for binding variables to parameters or false (default) |
|
| 797 | + * @return ADORecordSet or false, if the query fails |
|
| 798 | + */ |
|
| 799 | 799 | function limit_query($Query_String, $offset, $line = '', $file = '', $num_rows = '',$inputarr=false) |
| 800 | 800 | { |
| 801 | 801 | return $this->query($Query_String,$line,$file,$offset,$num_rows,$inputarr); |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | - * Begin Transaction |
|
| 806 | - * |
|
| 807 | - * @return int/boolean current transaction-id, of false if no connection |
|
| 808 | - */ |
|
| 805 | + * Begin Transaction |
|
| 806 | + * |
|
| 807 | + * @return int/boolean current transaction-id, of false if no connection |
|
| 808 | + */ |
|
| 809 | 809 | function transaction_begin() |
| 810 | 810 | { |
| 811 | 811 | if (!$this->Link_ID && !$this->connect()) |
@@ -817,10 +817,10 @@ discard block |
||
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | - * Complete the transaction |
|
| 821 | - * |
|
| 822 | - * @return bool True if sucessful, False if fails |
|
| 823 | - */ |
|
| 820 | + * Complete the transaction |
|
| 821 | + * |
|
| 822 | + * @return bool True if sucessful, False if fails |
|
| 823 | + */ |
|
| 824 | 824 | function transaction_commit() |
| 825 | 825 | { |
| 826 | 826 | if (!$this->Link_ID && !$this->connect()) |
@@ -832,10 +832,10 @@ discard block |
||
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | /** |
| 835 | - * Rollback the current transaction |
|
| 836 | - * |
|
| 837 | - * @return bool True if sucessful, False if fails |
|
| 838 | - */ |
|
| 835 | + * Rollback the current transaction |
|
| 836 | + * |
|
| 837 | + * @return bool True if sucessful, False if fails |
|
| 838 | + */ |
|
| 839 | 839 | function transaction_abort() |
| 840 | 840 | { |
| 841 | 841 | if (!$this->Link_ID && !$this->connect()) |
@@ -847,12 +847,12 @@ discard block |
||
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | /** |
| 850 | - * Find the primary key of the last insertion on the current db connection |
|
| 851 | - * |
|
| 852 | - * @param string $table name of table the insert was performed on |
|
| 853 | - * @param string $field the autoincrement primary key of the table |
|
| 854 | - * @return int the id, -1 if fails |
|
| 855 | - */ |
|
| 850 | + * Find the primary key of the last insertion on the current db connection |
|
| 851 | + * |
|
| 852 | + * @param string $table name of table the insert was performed on |
|
| 853 | + * @param string $field the autoincrement primary key of the table |
|
| 854 | + * @return int the id, -1 if fails |
|
| 855 | + */ |
|
| 856 | 856 | function get_last_insert_id($table, $field) |
| 857 | 857 | { |
| 858 | 858 | if (!$this->Link_ID && !$this->connect()) |
@@ -875,10 +875,10 @@ discard block |
||
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | /** |
| 878 | - * Get the number of rows affected by last update or delete |
|
| 879 | - * |
|
| 880 | - * @return int number of rows |
|
| 881 | - */ |
|
| 878 | + * Get the number of rows affected by last update or delete |
|
| 879 | + * |
|
| 880 | + * @return int number of rows |
|
| 881 | + */ |
|
| 882 | 882 | function affected_rows() |
| 883 | 883 | { |
| 884 | 884 | if ($this->log_updates) return 0; |
@@ -891,14 +891,14 @@ discard block |
||
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | /** |
| 894 | - * Get description of a table |
|
| 895 | - * |
|
| 896 | - * Beside the column-name all other data depends on the db-type !!! |
|
| 897 | - * |
|
| 898 | - * @param string $table name of table to describe |
|
| 899 | - * @param bool $full optional, default False summary information, True full information |
|
| 900 | - * @return array table meta data |
|
| 901 | - */ |
|
| 894 | + * Get description of a table |
|
| 895 | + * |
|
| 896 | + * Beside the column-name all other data depends on the db-type !!! |
|
| 897 | + * |
|
| 898 | + * @param string $table name of table to describe |
|
| 899 | + * @param bool $full optional, default False summary information, True full information |
|
| 900 | + * @return array table meta data |
|
| 901 | + */ |
|
| 902 | 902 | function metadata($table='',$full=false) |
| 903 | 903 | { |
| 904 | 904 | if (!$this->Link_ID && !$this->connect()) |
@@ -980,10 +980,10 @@ discard block |
||
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
| 983 | - * Return a list of indexes in current database |
|
| 984 | - * |
|
| 985 | - * @return array list of indexes |
|
| 986 | - */ |
|
| 983 | + * Return a list of indexes in current database |
|
| 984 | + * |
|
| 985 | + * @return array list of indexes |
|
| 986 | + */ |
|
| 987 | 987 | function index_names() |
| 988 | 988 | { |
| 989 | 989 | $indices = array(); |
@@ -1004,10 +1004,10 @@ discard block |
||
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
| 1007 | - * Returns an array containing column names that are the primary keys of $tablename. |
|
| 1008 | - * |
|
| 1009 | - * @return array of columns |
|
| 1010 | - */ |
|
| 1007 | + * Returns an array containing column names that are the primary keys of $tablename. |
|
| 1008 | + * |
|
| 1009 | + * @return array of columns |
|
| 1010 | + */ |
|
| 1011 | 1011 | function pkey_columns($tablename) |
| 1012 | 1012 | { |
| 1013 | 1013 | if (!$this->Link_ID && !$this->connect()) |
@@ -1018,13 +1018,13 @@ discard block |
||
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | /** |
| 1021 | - * Create a new database |
|
| 1022 | - * |
|
| 1023 | - * @param string $adminname name of database administrator user (optional) |
|
| 1024 | - * @param string $adminpasswd password for the database administrator user (optional) |
|
| 1025 | - * @param string $charset default charset for the database |
|
| 1026 | - * @param string $grant_host ='localhost' host/ip of the webserver |
|
| 1027 | - */ |
|
| 1021 | + * Create a new database |
|
| 1022 | + * |
|
| 1023 | + * @param string $adminname name of database administrator user (optional) |
|
| 1024 | + * @param string $adminpasswd password for the database administrator user (optional) |
|
| 1025 | + * @param string $charset default charset for the database |
|
| 1026 | + * @param string $grant_host ='localhost' host/ip of the webserver |
|
| 1027 | + */ |
|
| 1028 | 1028 | function create_database($adminname = '', $adminpasswd = '', $charset='', $grant_host='localhost') |
| 1029 | 1029 | { |
| 1030 | 1030 | $currentUser = $this->User; |
@@ -1280,12 +1280,12 @@ discard block |
||
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | /** |
| 1283 | - * Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements |
|
| 1284 | - * |
|
| 1285 | - * This is mostly copy & paste from adodb's datadict class |
|
| 1286 | - * @param string $_name |
|
| 1287 | - * @return string quoted string |
|
| 1288 | - */ |
|
| 1283 | + * Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements |
|
| 1284 | + * |
|
| 1285 | + * This is mostly copy & paste from adodb's datadict class |
|
| 1286 | + * @param string $_name |
|
| 1287 | + * @return string quoted string |
|
| 1288 | + */ |
|
| 1289 | 1289 | function name_quote($_name = NULL) |
| 1290 | 1290 | { |
| 1291 | 1291 | if (!is_string($_name)) |
@@ -1324,19 +1324,19 @@ discard block |
||
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | /** |
| 1327 | - * Escape values before sending them to the database - prevents SQL injection and SQL errors ;-) |
|
| 1328 | - * |
|
| 1329 | - * Please note that the quote function already returns necessary quotes: quote('Hello') === "'Hello'". |
|
| 1330 | - * Int and Auto types are casted to int: quote('1','int') === 1, quote('','int') === 0, quote('Hello','int') === 0 |
|
| 1331 | - * Arrays of id's stored in strings: quote(array(1,2,3),'string') === "'1,2,3'" |
|
| 1332 | - * |
|
| 1333 | - * @param mixed $value the value to be escaped |
|
| 1334 | - * @param string|boolean $type =false string the type of the db-column, default False === varchar |
|
| 1335 | - * @param boolean $not_null =true is column NOT NULL, default true, else php null values are written as SQL NULL |
|
| 1336 | - * @param int $length =null length of the varchar column, to truncate it if the database requires it (eg. Postgres) |
|
| 1337 | - * @param string $glue =',' used to glue array values together for the string type |
|
| 1338 | - * @return string escaped sting |
|
| 1339 | - */ |
|
| 1327 | + * Escape values before sending them to the database - prevents SQL injection and SQL errors ;-) |
|
| 1328 | + * |
|
| 1329 | + * Please note that the quote function already returns necessary quotes: quote('Hello') === "'Hello'". |
|
| 1330 | + * Int and Auto types are casted to int: quote('1','int') === 1, quote('','int') === 0, quote('Hello','int') === 0 |
|
| 1331 | + * Arrays of id's stored in strings: quote(array(1,2,3),'string') === "'1,2,3'" |
|
| 1332 | + * |
|
| 1333 | + * @param mixed $value the value to be escaped |
|
| 1334 | + * @param string|boolean $type =false string the type of the db-column, default False === varchar |
|
| 1335 | + * @param boolean $not_null =true is column NOT NULL, default true, else php null values are written as SQL NULL |
|
| 1336 | + * @param int $length =null length of the varchar column, to truncate it if the database requires it (eg. Postgres) |
|
| 1337 | + * @param string $glue =',' used to glue array values together for the string type |
|
| 1338 | + * @return string escaped sting |
|
| 1339 | + */ |
|
| 1340 | 1340 | function quote($value,$type=False,$not_null=true,$length=null,$glue=',') |
| 1341 | 1341 | { |
| 1342 | 1342 | if ($this->Debug) echo "<p>db::quote(".(is_null($value)?'NULL':"'$value'").",'$type','$not_null')</p>\n"; |
@@ -1417,27 +1417,27 @@ discard block |
||
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | /** |
| 1420 | - * Implodes an array of column-value pairs for the use in sql-querys. |
|
| 1421 | - * All data is run through quote (does either addslashes() or (int)) - prevents SQL injunction and SQL errors ;-). |
|
| 1422 | - * |
|
| 1423 | - * @author RalfBecker<at>outdoor-training.de |
|
| 1424 | - * |
|
| 1425 | - * @param string $glue in most cases this will be either ',' or ' AND ', depending you your query |
|
| 1426 | - * @param array $array column-name / value pairs, if the value is an array all its array-values will be quoted |
|
| 1427 | - * according to the type of the column, and the whole array with be formatted like (val1,val2,...) |
|
| 1428 | - * If $use_key == True, an ' IN ' instead a '=' is used. Good for category- or user-lists. |
|
| 1429 | - * If the key is numerical (no key given in the array-definition) the value is used as is, eg. |
|
| 1430 | - * array('visits=visits+1') gives just "visits=visits+1" (no quoting at all !!!) |
|
| 1431 | - * @param boolean|string $use_key If $use_key===True a "$key=" prefix each value (default), typically set to False |
|
| 1432 | - * or 'VALUES' for insert querys, on 'VALUES' "(key1,key2,...) VALUES (val1,val2,...)" is returned |
|
| 1433 | - * @param array|boolean $only if set to an array only colums which are set (as data !!!) are written |
|
| 1434 | - * typicaly used to form a WHERE-clause from the primary keys. |
|
| 1435 | - * If set to True, only columns from the colum_definitons are written. |
|
| 1436 | - * @param array|boolean $column_definitions this can be set to the column-definitions-array |
|
| 1437 | - * of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file). |
|
| 1438 | - * If its set, the column-type-data determinates if (int) or addslashes is used. |
|
| 1439 | - * @return string SQL |
|
| 1440 | - */ |
|
| 1420 | + * Implodes an array of column-value pairs for the use in sql-querys. |
|
| 1421 | + * All data is run through quote (does either addslashes() or (int)) - prevents SQL injunction and SQL errors ;-). |
|
| 1422 | + * |
|
| 1423 | + * @author RalfBecker<at>outdoor-training.de |
|
| 1424 | + * |
|
| 1425 | + * @param string $glue in most cases this will be either ',' or ' AND ', depending you your query |
|
| 1426 | + * @param array $array column-name / value pairs, if the value is an array all its array-values will be quoted |
|
| 1427 | + * according to the type of the column, and the whole array with be formatted like (val1,val2,...) |
|
| 1428 | + * If $use_key == True, an ' IN ' instead a '=' is used. Good for category- or user-lists. |
|
| 1429 | + * If the key is numerical (no key given in the array-definition) the value is used as is, eg. |
|
| 1430 | + * array('visits=visits+1') gives just "visits=visits+1" (no quoting at all !!!) |
|
| 1431 | + * @param boolean|string $use_key If $use_key===True a "$key=" prefix each value (default), typically set to False |
|
| 1432 | + * or 'VALUES' for insert querys, on 'VALUES' "(key1,key2,...) VALUES (val1,val2,...)" is returned |
|
| 1433 | + * @param array|boolean $only if set to an array only colums which are set (as data !!!) are written |
|
| 1434 | + * typicaly used to form a WHERE-clause from the primary keys. |
|
| 1435 | + * If set to True, only columns from the colum_definitons are written. |
|
| 1436 | + * @param array|boolean $column_definitions this can be set to the column-definitions-array |
|
| 1437 | + * of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file). |
|
| 1438 | + * If its set, the column-type-data determinates if (int) or addslashes is used. |
|
| 1439 | + * @return string SQL |
|
| 1440 | + */ |
|
| 1441 | 1441 | function column_data_implode($glue,$array,$use_key=True,$only=False,$column_definitions=False) |
| 1442 | 1442 | { |
| 1443 | 1443 | if (!is_array($array)) // this allows to give an SQL-string for delete or update |
@@ -1523,14 +1523,14 @@ discard block |
||
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | /** |
| 1526 | - * Sets the default column-definitions for use with column_data_implode() |
|
| 1527 | - * |
|
| 1528 | - * @author RalfBecker<at>outdoor-training.de |
|
| 1529 | - * |
|
| 1530 | - * @param array|boolean $column_definitions this can be set to the column-definitions-array |
|
| 1531 | - * of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file). |
|
| 1532 | - * If its set, the column-type-data determinates if (int) or addslashes is used. |
|
| 1533 | - */ |
|
| 1526 | + * Sets the default column-definitions for use with column_data_implode() |
|
| 1527 | + * |
|
| 1528 | + * @author RalfBecker<at>outdoor-training.de |
|
| 1529 | + * |
|
| 1530 | + * @param array|boolean $column_definitions this can be set to the column-definitions-array |
|
| 1531 | + * of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file). |
|
| 1532 | + * If its set, the column-type-data determinates if (int) or addslashes is used. |
|
| 1533 | + */ |
|
| 1534 | 1534 | function set_column_definitions($column_definitions=False) |
| 1535 | 1535 | { |
| 1536 | 1536 | $this->column_definitions=$column_definitions; |
@@ -1570,17 +1570,17 @@ discard block |
||
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | /** |
| 1573 | - * reads the table-definitions from the app's setup/tables_current.inc.php file |
|
| 1574 | - * |
|
| 1575 | - * The already read table-definitions are shared between all db-instances via a static var. |
|
| 1576 | - * |
|
| 1577 | - * @author RalfBecker<at>outdoor-training.de |
|
| 1578 | - * |
|
| 1579 | - * @param bool|string $app name of the app or default False to use the app set by db::set_app or the current app, |
|
| 1580 | - * true to search the already loaded table-definitions for $table and then search all existing apps for it |
|
| 1581 | - * @param bool|string $table if set return only defintions of that table, else return all defintions |
|
| 1582 | - * @return mixed array with table-defintions or False if file not found |
|
| 1583 | - */ |
|
| 1573 | + * reads the table-definitions from the app's setup/tables_current.inc.php file |
|
| 1574 | + * |
|
| 1575 | + * The already read table-definitions are shared between all db-instances via a static var. |
|
| 1576 | + * |
|
| 1577 | + * @author RalfBecker<at>outdoor-training.de |
|
| 1578 | + * |
|
| 1579 | + * @param bool|string $app name of the app or default False to use the app set by db::set_app or the current app, |
|
| 1580 | + * true to search the already loaded table-definitions for $table and then search all existing apps for it |
|
| 1581 | + * @param bool|string $table if set return only defintions of that table, else return all defintions |
|
| 1582 | + * @return mixed array with table-defintions or False if file not found |
|
| 1583 | + */ |
|
| 1584 | 1584 | function get_table_definitions($app=False,$table=False) |
| 1585 | 1585 | { |
| 1586 | 1586 | // ease the transition to api |
@@ -1676,21 +1676,21 @@ discard block |
||
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | 1678 | /** |
| 1679 | - * Insert a row of data into a table or updates it if $where is given, all data is quoted according to it's type |
|
| 1680 | - * |
|
| 1681 | - * @author RalfBecker<at>outdoor-training.de |
|
| 1682 | - * |
|
| 1683 | - * @param string $table name of the table |
|
| 1684 | - * @param array $data with column-name / value pairs |
|
| 1685 | - * @param mixed $where string with where clause or array with column-name / values pairs to check if a row with that keys already exists, or false for an unconditional insert |
|
| 1686 | - * if the row exists db::update is called else a new row with $date merged with $where gets inserted (data has precedence) |
|
| 1687 | - * @param int $line line-number to pass to query |
|
| 1688 | - * @param string $file file-name to pass to query |
|
| 1689 | - * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1690 | - * @param bool $use_prepared_statement use a prepared statement |
|
| 1691 | - * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1692 | - * @return ADORecordSet or false, if the query fails |
|
| 1693 | - */ |
|
| 1679 | + * Insert a row of data into a table or updates it if $where is given, all data is quoted according to it's type |
|
| 1680 | + * |
|
| 1681 | + * @author RalfBecker<at>outdoor-training.de |
|
| 1682 | + * |
|
| 1683 | + * @param string $table name of the table |
|
| 1684 | + * @param array $data with column-name / value pairs |
|
| 1685 | + * @param mixed $where string with where clause or array with column-name / values pairs to check if a row with that keys already exists, or false for an unconditional insert |
|
| 1686 | + * if the row exists db::update is called else a new row with $date merged with $where gets inserted (data has precedence) |
|
| 1687 | + * @param int $line line-number to pass to query |
|
| 1688 | + * @param string $file file-name to pass to query |
|
| 1689 | + * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1690 | + * @param bool $use_prepared_statement use a prepared statement |
|
| 1691 | + * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1692 | + * @return ADORecordSet or false, if the query fails |
|
| 1693 | + */ |
|
| 1694 | 1694 | function insert($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False) |
| 1695 | 1695 | { |
| 1696 | 1696 | if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app')</p>\n"; |
@@ -1786,20 +1786,20 @@ discard block |
||
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | 1788 | /** |
| 1789 | - * Updates the data of one or more rows in a table, all data is quoted according to it's type |
|
| 1790 | - * |
|
| 1791 | - * @author RalfBecker<at>outdoor-training.de |
|
| 1792 | - * |
|
| 1793 | - * @param string $table name of the table |
|
| 1794 | - * @param array $data with column-name / value pairs |
|
| 1795 | - * @param array $where column-name / values pairs and'ed together for the where clause |
|
| 1796 | - * @param int $line line-number to pass to query |
|
| 1797 | - * @param string $file file-name to pass to query |
|
| 1798 | - * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1799 | - * @param bool $use_prepared_statement use a prepared statement |
|
| 1800 | - * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1801 | - * @return ADORecordSet or false, if the query fails |
|
| 1802 | - */ |
|
| 1789 | + * Updates the data of one or more rows in a table, all data is quoted according to it's type |
|
| 1790 | + * |
|
| 1791 | + * @author RalfBecker<at>outdoor-training.de |
|
| 1792 | + * |
|
| 1793 | + * @param string $table name of the table |
|
| 1794 | + * @param array $data with column-name / value pairs |
|
| 1795 | + * @param array $where column-name / values pairs and'ed together for the where clause |
|
| 1796 | + * @param int $line line-number to pass to query |
|
| 1797 | + * @param string $file file-name to pass to query |
|
| 1798 | + * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1799 | + * @param bool $use_prepared_statement use a prepared statement |
|
| 1800 | + * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1801 | + * @return ADORecordSet or false, if the query fails |
|
| 1802 | + */ |
|
| 1803 | 1803 | function update($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False) |
| 1804 | 1804 | { |
| 1805 | 1805 | if ($this->Debug) echo "<p>db::update('$table',".print_r($data,true).','.print_r($where,true).",$line,$file,'$app')</p>\n"; |
@@ -1876,18 +1876,18 @@ discard block |
||
| 1876 | 1876 | } |
| 1877 | 1877 | |
| 1878 | 1878 | /** |
| 1879 | - * Deletes one or more rows in table, all data is quoted according to it's type |
|
| 1880 | - * |
|
| 1881 | - * @author RalfBecker<at>outdoor-training.de |
|
| 1882 | - * |
|
| 1883 | - * @param string $table name of the table |
|
| 1884 | - * @param array $where column-name / values pairs and'ed together for the where clause |
|
| 1885 | - * @param int $line line-number to pass to query |
|
| 1886 | - * @param string $file file-name to pass to query |
|
| 1887 | - * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1888 | - * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1889 | - * @return ADORecordSet or false, if the query fails |
|
| 1890 | - */ |
|
| 1879 | + * Deletes one or more rows in table, all data is quoted according to it's type |
|
| 1880 | + * |
|
| 1881 | + * @author RalfBecker<at>outdoor-training.de |
|
| 1882 | + * |
|
| 1883 | + * @param string $table name of the table |
|
| 1884 | + * @param array $where column-name / values pairs and'ed together for the where clause |
|
| 1885 | + * @param int $line line-number to pass to query |
|
| 1886 | + * @param string $file file-name to pass to query |
|
| 1887 | + * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1888 | + * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1889 | + * @return ADORecordSet or false, if the query fails |
|
| 1890 | + */ |
|
| 1891 | 1891 | function delete($table,$where,$line,$file,$app=False,$table_def=False) |
| 1892 | 1892 | { |
| 1893 | 1893 | if (!$table_def) $table_def = $this->get_table_definitions($app,$table); |
@@ -1953,25 +1953,25 @@ discard block |
||
| 1953 | 1953 | } |
| 1954 | 1954 | |
| 1955 | 1955 | /** |
| 1956 | - * Selects one or more rows in table depending on where, all data is quoted according to it's type |
|
| 1957 | - * |
|
| 1958 | - * @author RalfBecker<at>outdoor-training.de |
|
| 1959 | - * |
|
| 1960 | - * @param string $table name of the table |
|
| 1961 | - * @param array|string $cols string or array of column-names / select-expressions |
|
| 1962 | - * @param array|string $where string or array with column-name / values pairs AND'ed together for the where clause |
|
| 1963 | - * @param int $line line-number to pass to query |
|
| 1964 | - * @param string $file file-name to pass to query |
|
| 1965 | - * @param int|bool $offset offset for a limited query or False (default) |
|
| 1966 | - * @param string $append string to append to the end of the query, eg. ORDER BY ... |
|
| 1967 | - * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1968 | - * @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs |
|
| 1969 | - * @param string $join =null sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
|
| 1970 | - * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! |
|
| 1971 | - * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1972 | - * @param int $fetchmode =self::FETCH_ASSOC self::FETCH_ASSOC (default), self::FETCH_BOTH or self::FETCH_NUM |
|
| 1973 | - * @return ADORecordSet or false, if the query fails |
|
| 1974 | - */ |
|
| 1956 | + * Selects one or more rows in table depending on where, all data is quoted according to it's type |
|
| 1957 | + * |
|
| 1958 | + * @author RalfBecker<at>outdoor-training.de |
|
| 1959 | + * |
|
| 1960 | + * @param string $table name of the table |
|
| 1961 | + * @param array|string $cols string or array of column-names / select-expressions |
|
| 1962 | + * @param array|string $where string or array with column-name / values pairs AND'ed together for the where clause |
|
| 1963 | + * @param int $line line-number to pass to query |
|
| 1964 | + * @param string $file file-name to pass to query |
|
| 1965 | + * @param int|bool $offset offset for a limited query or False (default) |
|
| 1966 | + * @param string $append string to append to the end of the query, eg. ORDER BY ... |
|
| 1967 | + * @param string|boolean $app string with name of app or False to use the current-app |
|
| 1968 | + * @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs |
|
| 1969 | + * @param string $join =null sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
|
| 1970 | + * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! |
|
| 1971 | + * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline |
|
| 1972 | + * @param int $fetchmode =self::FETCH_ASSOC self::FETCH_ASSOC (default), self::FETCH_BOTH or self::FETCH_NUM |
|
| 1973 | + * @return ADORecordSet or false, if the query fails |
|
| 1974 | + */ |
|
| 1975 | 1975 | function select($table,$cols,$where,$line,$file,$offset=False,$append='',$app=False,$num_rows=0,$join='',$table_def=False,$fetchmode=self::FETCH_ASSOC) |
| 1976 | 1976 | { |
| 1977 | 1977 | if ($this->Debug) echo "<p>db::select('$table',".print_r($cols,True).",".print_r($where,True).",$line,$file,$offset,'$app',$num_rows,'$join')</p>\n"; |
@@ -2006,20 +2006,20 @@ discard block |
||
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | 2008 | /** |
| 2009 | - * Does a union over multiple selects |
|
| 2010 | - * |
|
| 2011 | - * @author RalfBecker<at>outdoor-training.de |
|
| 2012 | - * |
|
| 2013 | - * @param array $selects array of selects, each select is an array with the possible keys/parameters: table, cols, where, append, app, join, table_def |
|
| 2014 | - * For further info about parameters see the definition of the select function, beside table, cols and where all other params are optional |
|
| 2015 | - * @param int $line line-number to pass to query |
|
| 2016 | - * @param string $file file-name to pass to query |
|
| 2017 | - * @param string $order_by ORDER BY statement for the union |
|
| 2018 | - * @param int|bool $offset offset for a limited query or False (default) |
|
| 2019 | - * @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs |
|
| 2020 | - * @param int $fetchmode =self::FETCH_ASSOC self::FETCH_ASSOC (default), self::FETCH_BOTH or self::FETCH_NUM |
|
| 2021 | - * @return ADORecordSet or false, if the query fails |
|
| 2022 | - */ |
|
| 2009 | + * Does a union over multiple selects |
|
| 2010 | + * |
|
| 2011 | + * @author RalfBecker<at>outdoor-training.de |
|
| 2012 | + * |
|
| 2013 | + * @param array $selects array of selects, each select is an array with the possible keys/parameters: table, cols, where, append, app, join, table_def |
|
| 2014 | + * For further info about parameters see the definition of the select function, beside table, cols and where all other params are optional |
|
| 2015 | + * @param int $line line-number to pass to query |
|
| 2016 | + * @param string $file file-name to pass to query |
|
| 2017 | + * @param string $order_by ORDER BY statement for the union |
|
| 2018 | + * @param int|bool $offset offset for a limited query or False (default) |
|
| 2019 | + * @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs |
|
| 2020 | + * @param int $fetchmode =self::FETCH_ASSOC self::FETCH_ASSOC (default), self::FETCH_BOTH or self::FETCH_NUM |
|
| 2021 | + * @return ADORecordSet or false, if the query fails |
|
| 2022 | + */ |
|
| 2023 | 2023 | function union($selects,$line,$file,$order_by='',$offset=false,$num_rows=0,$fetchmode=self::FETCH_ASSOC) |
| 2024 | 2024 | { |
| 2025 | 2025 | if ($this->Debug) echo "<p>db::union(".print_r($selects,True).",$line,$file,$order_by,$offset,$num_rows)</p>\n"; |