
Public Member Functions | |
| check () | |
| getDatabase () | |
| getNumRows ($cur=null) | |
| getAffectedRows () | |
| insert () | |
| update ($updateNulls=true) | |
| load ($key=null) | |
| store ($updateNulls=false) | |
| bind ($array, $ignore='', $strip=true) | |
| bindOnly ($array, $accept='', $strip=true) | |
| lacks ($property) | |
| move ($direction, $where='') | |
| updateOrder ($where='', $sequence='', $orders=array()) | |
| delete ($key=null) | |
| checkout ($who, $key=null) | |
| checkin ($key=null) | |
| isCheckedOut ($userid=0) | |
Public Attributes | |
| $_error = '' | |
Private Member Functions | |
| bindDoWork ($array, $fields, $strip) | |
| stripMagicQuotes ($field) | |
Definition at line 15 of file aliroDatabaseRow.php.
| aliroDBGeneralRow::check | ( | ) |
Reimplemented in aliroModule, and mosUser.
Definition at line 18 of file aliroDatabaseRow.php.
Referenced by mosDBTable::save().
| aliroDBGeneralRow::getDatabase | ( | ) |
Definition at line 22 of file aliroDatabaseRow.php.
Referenced by aliroDatabaseRow::__get(), bind(), bindOnly(), checkin(), checkout(), delete(), mosDBTable::filter(), getAffectedRows(), getNumRows(), mosDBTable::hit(), insert(), lacks(), load(), move(), mosDBTable::publish_array(), mosDBTable::reset(), store(), mosDBTable::toXML(), update(), and updateOrder().
| aliroDBGeneralRow::getNumRows | ( | $ | cur = null |
) |
Definition at line 26 of file aliroDatabaseRow.php.
References getDatabase().
00026 { 00027 return $this->getDatabase()->getNumRows($cur); 00028 }
| aliroDBGeneralRow::getAffectedRows | ( | ) |
Definition at line 30 of file aliroDatabaseRow.php.
References getDatabase().
00030 { 00031 return $this->getDatabase()->getAffectedRows(); 00032 }
| aliroDBGeneralRow::insert | ( | ) |
Definition at line 34 of file aliroDatabaseRow.php.
References getDatabase().
Referenced by store(), and mosUser::userStore().
00034 { 00035 return $this->getDatabase()->insertObject($this->tableName, $this, $this->rowKey); 00036 }
| aliroDBGeneralRow::update | ( | $ | updateNulls = true |
) |
Definition at line 38 of file aliroDatabaseRow.php.
References getDatabase().
Referenced by store(), and mosUser::userStore().
00038 { 00039 return $this->getDatabase()->updateObject($this->tableName, $this, $this->rowKey, $updateNulls); 00040 }
| aliroDBGeneralRow::load | ( | $ | key = null |
) |
Reimplemented in aliroFolder, and aliroMenuItem.
Definition at line 42 of file aliroDatabaseRow.php.
References getDatabase().
00042 { 00043 $k = $this->rowKey; 00044 if (null !== $key) $this->$k = $key; 00045 if (empty($this->$k)) return false; 00046 $this->getDatabase()->setQuery("SELECT * FROM $this->tableName WHERE $this->rowKey='{$this->$k}'" ); 00047 return $this->getDatabase()->loadObject($this); 00048 }
| aliroDBGeneralRow::store | ( | $ | updateNulls = false |
) |
Reimplemented in aliroAdminMenu.
Definition at line 50 of file aliroDatabaseRow.php.
References getDatabase(), insert(), and update().
Referenced by aliroErrorRecorder::recordError(), and mosDBTable::save().
00050 { 00051 $k = $this->rowKey; 00052 $ret = $this->$k ? $this->update($updateNulls) : $this->insert(); 00053 if (!$ret) $this->_error = strtolower(get_class( $this ))."::store failed <br />" . $this->getDatabase()->getErrorMsg(); 00054 return $ret; 00055 }
| aliroDBGeneralRow::bind | ( | $ | array, | |
| $ | ignore = '', |
|||
| $ | strip = true | |||
| ) |
Definition at line 57 of file aliroDatabaseRow.php.
References bindDoWork(), and getDatabase().
Referenced by mosDBTable::save().
00057 { 00058 $fields = $this->getDatabase()->getAllFieldNames ($this->tableName); 00059 foreach ($fields as $key=>$field) if (false !== strpos($ignore, $field)) unset($fields[$key]); 00060 return $this->bindDoWork ($array, $fields, $strip); 00061 }
| aliroDBGeneralRow::bindOnly | ( | $ | array, | |
| $ | accept = '', |
|||
| $ | strip = true | |||
| ) |
Definition at line 63 of file aliroDatabaseRow.php.
References bindDoWork(), and getDatabase().
00063 { 00064 $fields = $this->getDatabase()->getAllFieldNames ($this->tableName); 00065 foreach ($fields as $key=>$field) if (false === strpos($accept, $field)) unset($fields[$key]); 00066 return $this->bindDoWork ($array, $fields, $strip); 00067 }
| aliroDBGeneralRow::bindDoWork | ( | $ | array, | |
| $ | fields, | |||
| $ | strip | |||
| ) | [private] |
Definition at line 69 of file aliroDatabaseRow.php.
References aliroRequest::getInstance(), and stripMagicQuotes().
Referenced by bind(), and bindOnly().
00069 { 00070 if (is_array($array)) { 00071 $request = aliroRequest::getInstance(); 00072 foreach ($fields as $field) if (isset($array[$field])) { 00073 $this->$field = $strip ? $this->stripMagicQuotes($array[$field]) : $array[$field]; 00074 if ('params' != $field AND (false !== strpos($this->$field, '&') OR false !== strpos($this->$field, '<'))) { 00075 $this->$field = $request->doPurify($this->$field); 00076 } 00077 } 00078 return true; 00079 } 00080 $this->_error = strtolower(get_class($this)).T_('::bind failed, parameter not an array'); 00081 return false; 00082 }
| aliroDBGeneralRow::stripMagicQuotes | ( | $ | field | ) | [private] |
Definition at line 84 of file aliroDatabaseRow.php.
Referenced by bindDoWork().
00084 { 00085 return (get_magic_quotes_gpc() AND is_string($field)) ? stripslashes($field) : $field; 00086 }
| aliroDBGeneralRow::lacks | ( | $ | property | ) |
Definition at line 88 of file aliroDatabaseRow.php.
References getDatabase(), and T_().
Referenced by checkin(), checkout(), and updateOrder().
00088 { 00089 if (in_array($property, $this->getDatabase()->getAllFieldNames($this->tableName))) return false; 00090 $this->_error = sprintf (T_('WARNING: %s does not support %s.'), get_class($this), $property); 00091 return true; 00092 }
| aliroDBGeneralRow::move | ( | $ | direction, | |
| $ | where = '' | |||
| ) |
Definition at line 94 of file aliroDatabaseRow.php.
References getDatabase().
00094 { 00095 $compops = array (-1 => '<', 0 => '=', 1 => '>'); 00096 $relation = $compops[($direction>0)-($direction<0)]; 00097 $ordering = ($relation == '<' ? 'DESC' : 'ASC'); 00098 $k = $this->rowKey; 00099 $o1 = $this->ordering; 00100 $k1 = $this->$k; 00101 $database = $this->getDatabase(); 00102 $sql = "SELECT $k, ordering FROM $this->tableName WHERE ordering $relation $o1"; 00103 $sql .= ($where ? "\n AND $where" : '').' ORDER BY ordering '.$ordering.' LIMIT 1'; 00104 $database->setQuery( $sql ); 00105 if ($database->loadObject($row)) { 00106 $o2 = $row->ordering; 00107 $k2 = $row->$k; 00108 $sql = "UPDATE $this->tableName SET ordering = (ordering=$o1)*$o2 + (ordering=$o2)*$o1 WHERE $k = $k1 OR $k = $k2"; 00109 $database->doSQL($sql); 00110 } 00111 }
| aliroDBGeneralRow::updateOrder | ( | $ | where = '', |
|
| $ | sequence = '', |
|||
| $ | orders = array() | |||
| ) |
Definition at line 114 of file aliroDatabaseRow.php.
References getDatabase(), and lacks().
Referenced by mosDBTable::save().
00114 { 00115 if ($this->lacks('ordering')) return false; 00116 $sql = "SELECT $this->rowKey, ordering FROM $this->tableName" 00117 .($where ? "\n WHERE $where" : '') 00118 ."\n ORDER BY ordering" 00119 .($sequence ? ','.$sequence : ''); 00120 $rows = $this->getDatabase()->doSQLget($sql, 'stdClass', $this->rowKey); 00121 $allrows = array(); 00122 foreach ($rows as $key=>$row) $allrows[(isset($orders[$key]) ? $orders[$key] : $row->ordering)] = $key; 00123 ksort($allrows); 00124 $cases = ''; 00125 $order = 10; 00126 foreach ($allrows as $ordering=>$id) { 00127 if ($order != $rows[$id]->ordering) $cases .= " WHEN $this->rowKey = $id THEN $order "; 00128 $order += 10; 00129 } 00130 if ($cases) $this->getDatabase()->doSQL("UPDATE $this->tableName SET ordering = CASE ".$cases.' ELSE ordering END'); 00131 return true; 00132 }
| aliroDBGeneralRow::delete | ( | $ | key = null |
) |
Reimplemented in mosUser.
Definition at line 135 of file aliroDatabaseRow.php.
References getDatabase().
00135 { 00136 $k = $this->rowKey; 00137 if ($key) $this->$k = intval( $key ); 00138 $this->getDatabase()->doSQL( "DELETE FROM $this->tableName WHERE $this->rowKey = '".$this->$k."'" ); 00139 return true; 00140 }
| aliroDBGeneralRow::checkout | ( | $ | who, | |
| $ | key = null | |||
| ) |
Definition at line 142 of file aliroDatabaseRow.php.
References getDatabase(), and lacks().
00142 { 00143 if ($this->lacks('checked_out')) return false; 00144 $k = $this->rowKey; 00145 if (null !== $key) $this->$k = $key; 00146 $time = date( "%Y-%m-%d H:i:s" ); 00147 $this->getDatabase()->doSQL( "UPDATE $this->tableName" 00148 . "\nSET checked_out='$who', checked_out_time='$time'" 00149 . "\nWHERE $k='".$this->$k."'" 00150 ); 00151 return true; 00152 }
| aliroDBGeneralRow::checkin | ( | $ | key = null |
) |
Definition at line 154 of file aliroDatabaseRow.php.
References getDatabase(), and lacks().
Referenced by mosDBTable::save().
00154 { 00155 if ($this->lacks('checked_out')) return false; 00156 $k = $this->rowKey; 00157 if (null !== $key) $this->$k = $key; 00158 $this->getDatabase()->doSQL( "UPDATE $this->tableName" 00159 . "\nSET checked_out='0', checked_out_time='0000-00-00 00:00:00'" 00160 . "\nWHERE $k='".$this->$k."'" 00161 ); 00162 return true; 00163 }
| aliroDBGeneralRow::isCheckedOut | ( | $ | userid = 0 |
) |
| aliroDBGeneralRow::$_error = '' |
Definition at line 16 of file aliroDatabaseRow.php.
1.5.5