ط¯ط±ط³ ظ…طھظ‚ط¯ظ… : ظƒظ„ط§ط³ ط§ظ„طھط*ظƒظ… ط¨ظ‚ظˆط§ط¹ط¯ ط§ظ„ط¨ظٹط§ظ†ط§طھ ( Class_db)



السلام عليكم و رحمة الله وبركاته

إخواني الكرام ما راح اطول عليكم كثيير لانه مشاغل الدنيا كثييرة مرة و انا شايف نفسي ما اجد حتي الوقت لاكل ههه

علي كل اعرض عليكم هالكلاس ( الي هو من برمجتي )
ان شاء الله يفيدكم كثييير و ربح الكثيير من الوقت
وهو للتعامل مع جميييع انواع الاستعالمات من قواعد البيانات

( في هذا الكلاس عملت خاصية Seclect و خاصية جلب rows و سيتم اضافة بقية الخصائص بكرا ان شاء الله )

ملف interfaces.class.php

رمز PHP:
<code style="white-space:nowrap"> <code> Interface Option
{
public function
SqlCde ($requete) ;
public function
sqlQuery ($SqlSelec,$role,$sqlarray) ;
}
</code> </code>

رمز PHP:
<code style="white-space:nowrap"> <code> include ("interfaces.class.php") ;
Class
EditClass implements ArrayAccess
{

Private
$ficher ;
Private
$valeur ;
Public
$variable;
Public
$check ;

public function
offsetset($var,$valeur){
global
$var ;
$this->var=$valeur;
}



public function
offsetexists($name) {

Switch (
"variable") {

case
'ficher' :
if (!
file_exists($name)){
Global
$check ;
$this->Check = FALSE ;
}
else { Global
$check ;
$this->Check = TRUE ; }

case
'variable' :
if ( empty(
$name) and !isset ($name)) {
Global
$check ;
$this->Check = FALSE ;
}
else { Global
$check ;
$this->Check = TRUE ; }
}
}
public function
offsetunset ($valeur){
unset (
$valeur) ;
}



public function
offsetget ($ficher){
return
$this->ficher ;
}
}

Class
ScriptOption extends EditClass implements option
{

Private
$sqlarray;
Private
$sqlcode ;
Private
$role ;
Public
$key ;

public function
SqlCde ($sqlarray) {

$sqlcode = new ArrayIterator($sqlarray) ;
$sqlcode->ksort() ;
Global
$key ;
foreach (
$sqlcode as $key=> $value ) {
define ( $key , $sqlcode&#91;$key&#93; ) ;
}
}
public function
sqlQuery ($SqlSelec,$role,$sqlarray) {

$offsetexists = new EditClass() ;
$offsetexists->offsetexists($SqlSelec) ;
if (
$offsetexists->Check) {
$this->mysql_query = mysql_query ($SqlSelec) ;
Switch (
$role) {
case
"fetch_row" :
global
$value ;
$value = array() ;
while (
$rows = mysql_fetch_row($this->mysql_query)){
$sqlcode = new ArrayIterator($sqlarray) ;
$sqlcode->ksort() ;
foreach (
$sqlcode as $key=> $valeur ) {
array_push( $value , $rows&#91; $sqlcode&#91;$key&#93;&#93; ) ;

}

}
}

}
}
}

$yo = new ScriptOption() ;

$yo->SqlCde (array ( "sql1"=>"select * from user",
"sql2"=>"select * from table ",
"sql2"=>"select * from name " ,
"sql2"=>"select * from user "
)) ;

### 6 and 4 the num of rows in array sql
$yo->sqlQuery( sql1 , "fetch_row" , array ( "lol"=>6 ,
"sql2"=>4

)) ;
echo
$value&#91;0&#93; ; ##### get the rows 0 of array rows 6
</code> </code>

اخوكم Fahedouch

موفقين يا رب




التعديل الأخير كان بواسطة fahedouch; 12 - 08 - 2014 الساعة 22:55





©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى©