php is not perl

This commit is contained in:
Jakob Sack 2011-04-15 19:24:23 +02:00
parent 3c01e30748
commit 3d89b2caa4
5 changed files with 45 additions and 48 deletions

View File

@ -53,14 +53,14 @@ class OC_GROUP_DATABASE extends OC_GROUP_BACKEND {
*/ */
public static function createGroup( $gid ){ public static function createGroup( $gid ){
$query = OC_DB::prepare( "SELECT * FROM `*PREFIX*groups` WHERE `gid` = ?" ); $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*groups` WHERE `gid` = ?" );
$result = $query->execute( $gid ); $result = $query->execute( array( $gid ));
if( $result->numRows() > 0 ){ if( $result->numRows() > 0 ){
return false; return false;
} }
else{ else{
$query = OC_DB::prepare( "INSERT INTO `*PREFIX*groups` ( `gid` ) VALUES( ? )" ); $query = OC_DB::prepare( "INSERT INTO `*PREFIX*groups` ( `gid` ) VALUES( ? )" );
$result = $query->prepare( $gid ); $result = $query->execute( array( $gid ));
return $result ? true : false; return $result ? true : false;
} }
@ -74,8 +74,7 @@ class OC_GROUP_DATABASE extends OC_GROUP_BACKEND {
*/ */
public static function inGroup( $username, $groupName ){ public static function inGroup( $username, $groupName ){
$query = OC_DB::prepare( "SELECT * FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` = ?" ); $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` = ?" );
$result = $query->execute( $groupName, $username ); $result = $query->execute( array( $groupName, $username ));
var_dump( $result );
return $result->numRows() > 0 ? true : false; return $result->numRows() > 0 ? true : false;
} }
@ -89,7 +88,7 @@ var_dump( $result );
public static function addToGroup( $username, $groupName ){ public static function addToGroup( $username, $groupName ){
if( !self::inGroup( $username, $groupName )){ if( !self::inGroup( $username, $groupName )){
$query = OC_DB::prepare( "INSERT INTO `*PREFIX*group_user` ( `uid`, `gid` ) VALUES( ?, ? )" ); $query = OC_DB::prepare( "INSERT INTO `*PREFIX*group_user` ( `uid`, `gid` ) VALUES( ?, ? )" );
$result = $query->execute( $username, $groupName ); $result = $query->execute( array( $username, $groupName ));
} }
} }
@ -101,7 +100,7 @@ var_dump( $result );
*/ */
public static function removeFromGroup( $username, $groupName ){ public static function removeFromGroup( $username, $groupName ){
$query = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE `uid` = ? AND `gid` = ?" ); $query = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE `uid` = ? AND `gid` = ?" );
$result = $query->execute( $username, $groupName ); $result = $query->execute( array( $username, $groupName ));
} }
/** /**
@ -111,7 +110,7 @@ var_dump( $result );
*/ */
public static function getUserGroups( $username ){ public static function getUserGroups( $username ){
$query = OC_DB::prepare( "SELECT * FROM `*PREFIX*group_user` WHERE `uid` = ?" ); $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*group_user` WHERE `uid` = ?" );
$result = $query->execute( $username ); $result = $query->execute( array( $username ));
$groups = array(); $groups = array();
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){

View File

@ -50,7 +50,7 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
*/ */
public static function createUser( $uid, $password ){ public static function createUser( $uid, $password ){
$query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE `uid` = ?" ); $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE `uid` = ?" );
$result = $query->execute( $uid ); $result = $query->execute( array( $uid ));
// Check if the user already exists // Check if the user already exists
if ( $result->numRows() > 0 ){ if ( $result->numRows() > 0 ){
@ -58,7 +58,7 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
} }
else{ else{
$query = OC_DB::prepare( "INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )" ); $query = OC_DB::prepare( "INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )" );
$result = $query->prepare( $uid, sha1( $password )); $result = $query->execute( array( $uid, sha1( $password )));
return $result ? true : false; return $result ? true : false;
} }
@ -72,7 +72,7 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
*/ */
public static function login( $username, $password ){ public static function login( $username, $password ){
$query = OC_DB::prepare( "SELECT `uid`, `name` FROM `*PREFIX*users` WHERE `uid` = ? AND `password` = ?" ); $query = OC_DB::prepare( "SELECT `uid`, `name` FROM `*PREFIX*users` WHERE `uid` = ? AND `password` = ?" );
$result = $query->execute( $username, sha1( $password )); $result = $query->execute( array( $username, sha1( $password )));
if( $result->numRows() > 0 ){ if( $result->numRows() > 0 ){
$row = $result->fetchRow(); $row = $result->fetchRow();
@ -121,7 +121,7 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
*/ */
public static function setPassword( $username, $password ){ public static function setPassword( $username, $password ){
$query = OC_DB::prepare( "UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?" ); $query = OC_DB::prepare( "UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?" );
$result = $query->execute( sha1( $password ), $username ); $result = $query->execute( array( sha1( $password ), $username ));
if( $result->numRows() > 0 ){ if( $result->numRows() > 0 ){
return true; return true;
@ -139,7 +139,7 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
*/ */
public static function checkPassword( $username, $password ){ public static function checkPassword( $username, $password ){
$query = OC_DB::prepare( "SELECT `uid` FROM `*PREFIX*users` WHERE `uid` = ? AND `password` = ?" ); $query = OC_DB::prepare( "SELECT `uid` FROM `*PREFIX*users` WHERE `uid` = ? AND `password` = ?" );
$result = $query->execute( $username, sha1( $password )); $result = $query->execute( array( $username, sha1( $password )));
if( $result->numRows() > 0 ){ if( $result->numRows() > 0 ){
return true; return true;

View File

@ -69,7 +69,7 @@ class OC_APPCONFIG{
public static function getKeys( $app ){ public static function getKeys( $app ){
// No magic in here as well // No magic in here as well
$query = OC_DB::prepare( 'SELECT `key` FROM `*PREFIX*appconfig` WHERE `appid` = ?' ); $query = OC_DB::prepare( 'SELECT `key` FROM `*PREFIX*appconfig` WHERE `appid` = ?' );
$result = $query->execute( $app ); $result = $query->execute( array( $app ));
$keys = array(); $keys = array();
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){
@ -92,7 +92,7 @@ class OC_APPCONFIG{
public static function getValue( $app, $key, $default = null ){ public static function getValue( $app, $key, $default = null ){
// At least some magic in here :-) // At least some magic in here :-)
$query = OC_DB::prepare( 'SELECT `value` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `key` = ?' ); $query = OC_DB::prepare( 'SELECT `value` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `key` = ?' );
$result = $query->execute( $app, $key ); $result = $query->execute( array( $app, $key ));
if( !$result->numRows()){ if( !$result->numRows()){
return $default; return $default;
@ -119,11 +119,11 @@ class OC_APPCONFIG{
// null: does not exist // null: does not exist
if( is_null( $exists )){ if( is_null( $exists )){
$query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `key`, `value` ) VALUES( ?, ?, ? )' ); $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `key`, `value` ) VALUES( ?, ?, ? )' );
$query->execute( $app, $key, $value ); $query->execute( array( $app, $key, $value ));
} }
else{ else{
$query = OC_DB::prepare( 'UPDATE `*PREFIX*appconfig` SET `value` = ? WHERE `appid` = ? AND `key` = ?' ); $query = OC_DB::prepare( 'UPDATE `*PREFIX*appconfig` SET `value` = ? WHERE `appid` = ? AND `key` = ?' );
$query->execute( $value, $app, $key ); $query->execute( array( $value, $app, $key ));
} }
} }
@ -138,7 +138,7 @@ class OC_APPCONFIG{
public static function deleteKey( $app, $key ){ public static function deleteKey( $app, $key ){
// Boring! // Boring!
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `key` = ?' ); $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `key` = ?' );
$query->execute( $app, $key ); $query->execute( array( $app, $key ));
return true; return true;
} }
@ -153,7 +153,7 @@ class OC_APPCONFIG{
public static function deleteApp( $app ){ public static function deleteApp( $app ){
// Nothing special // Nothing special
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ?' ); $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ?' );
$query->execute( $app ); $query->execute( array( $app ));
return true; return true;
} }

View File

@ -478,8 +478,6 @@ class OC_DB {
$query = self::processQuery( $query ); $query = self::processQuery( $query );
self::connect(); self::connect();
//fix differences between sql versions
// return the result // return the result
$result = self::$DBConnection->prepare( $query ); $result = self::$DBConnection->prepare( $query );

View File

@ -69,7 +69,7 @@ class OC_PREFERENCES{
public static function getApps( $user ){ public static function getApps( $user ){
// No need for more comments // No need for more comments
$query = OC_DB::prepare( 'SELECT DISTINCT( `appid` ) FROM `*PREFIX*preferences` WHERE `userid` = ?' ); $query = OC_DB::prepare( 'SELECT DISTINCT( `appid` ) FROM `*PREFIX*preferences` WHERE `userid` = ?' );
$result = $query->execute( $user ); $result = $query->execute( array( $user ));
$apps = array(); $apps = array();
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){
@ -91,7 +91,7 @@ class OC_PREFERENCES{
public static function getKeys( $user, $app ){ public static function getKeys( $user, $app ){
// No need for more comments // No need for more comments
$query = OC_DB::prepare( 'SELECT `key` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' ); $query = OC_DB::prepare( 'SELECT `key` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' );
$result = $query->execute( $user, $app ); $result = $query->execute( array( $user, $app ));
$keys = array(); $keys = array();
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){
@ -115,7 +115,7 @@ class OC_PREFERENCES{
public static function getValue( $user, $app, $key, $default = null ){ public static function getValue( $user, $app, $key, $default = null ){
// Try to fetch the value, return default if not exists. // Try to fetch the value, return default if not exists.
$query = OC_DB::prepare( 'SELECT `value` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `key` = ?' ); $query = OC_DB::prepare( 'SELECT `value` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `key` = ?' );
$result = $query->execute( $user, $app, $key ); $result = $query->execute( array( $user, $app, $key ));
if( !$result->numRows()){ if( !$result->numRows()){
return $default; return $default;
@ -144,11 +144,11 @@ class OC_PREFERENCES{
// null: does not exist. Insert. // null: does not exist. Insert.
if( is_null( $exists )){ if( is_null( $exists )){
$query = OC_DB::prepare( 'INSERT INTO `*PREFIX*preferences` ( `userid`, `appid`, `key`, `value` ) VALUES( ?, ?, ?, ? )' ); $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*preferences` ( `userid`, `appid`, `key`, `value` ) VALUES( ?, ?, ?, ? )' );
$query->execute( $user, $app, $key, $value ); $query->execute( array( $user, $app, $key, $value ));
} }
else{ else{
$query = OC_DB::prepare( 'UPDATE `*PREFIX*preferences` SET `value` = ? WHERE `userid` = ? AND `appid` = ? AND `key` = ?' ); $query = OC_DB::prepare( 'UPDATE `*PREFIX*preferences` SET `value` = ? WHERE `userid` = ? AND `appid` = ? AND `key` = ?' );
$query->execute( $value, $user, $app, $key ); $query->execute( array( $value, $user, $app, $key ));
} }
} }
@ -164,7 +164,7 @@ class OC_PREFERENCES{
public static function deleteKey( $user, $app, $key ){ public static function deleteKey( $user, $app, $key ){
// No need for more comments // No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `key` = ?' ); $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `key` = ?' );
$result = $query->execute( $user, $app, $key ); $result = $query->execute( array( $user, $app, $key ));
return true; return true;
} }
@ -180,7 +180,7 @@ class OC_PREFERENCES{
public static function deleteApp( $user, $app ){ public static function deleteApp( $user, $app ){
// No need for more comments // No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' ); $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' );
$result = $query->execute( $user, $app ); $result = $query->execute( array( $user, $app ));
return true; return true;
} }
@ -195,7 +195,7 @@ class OC_PREFERENCES{
public static function deleteUser( $user ){ public static function deleteUser( $user ){
// No need for more comments // No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ?' ); $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ?' );
$result = $query->execute( $user ); $result = $query->execute( array( $user ));
return true; return true;
} }
@ -210,7 +210,7 @@ class OC_PREFERENCES{
public static function deleteAppFromAllUsers( $app ){ public static function deleteAppFromAllUsers( $app ){
// No need for more comments // No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `appid` = ?' ); $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `appid` = ?' );
$result = $query->execute( $app ); $result = $query->execute( array( $app ));
return true; return true;
} }