Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PHPµÄCRUDÀà

ÒòΪÏîÄ¿ÐèÒª£¬ËùÒÔ×Ô¼ºÐ´ÁËÒ»¸öCRUDÀà
ËäÈ»»¹±È½Ï¼òµ¥£¬²»¹ý¸Ð¾õºÜʵÓá£
×¢£ºcls_databaseÊÇÒ»¸öÊý¾Ý¿â²Ù×÷Àà
¼û£ºhttp://code.google.com/p/cyy0523xc/source/browse/trunk/php/cls_crud.php
<?php
/**
* ×Ô¶¯»¯Êý¾Ý±í²Ù×÷Àà
* @author С²Ì <cyy0523xc@gmail.com>
* @version 1.0
*/
class cls_crud extends cls_database
{
/**
* Êý¾Ý±íÃû
* @var string
*/
private $table = '';
/**
* ¹¹Ô캯Êý
* @param array $config ÅäÖñäÁ¿
*/
public function __construct($config)
{
if(!empty($config))
{
foreach($config as $cf => $val)
{
$this->$cf = $val;
}
}
parent::__construct();
}
/**
* ÉèÖÃÊý¾Ý±í(ÀýÈ磺ÔÚ²Ù×÷µÄ¹ý³ÌÖÐÐèÒª¸Ä±äÊý¾Ý±í£¬¾Í¿ÉÒÔʹÓô˷½·¨)
* @param string $table
*/
public function set_table($table)
{
$this->table = $table;
}
/**
* ¶ÁÈ¡Ò»Ìõ¼Ç¼
* @param string $id Ö÷¼ü
* @param string $fields »ñÈ¡×Ö¶Î
* @return array
*/
public function read($id, $fields='*')
{
$sql = "SELECT {$fields} from `{$this->table}` WHERE `id`='{$id}'";
$this->query($sql);
return $this->fetch_one();
}
/**
* ²åÈëÒ»Ìõ¼Ç¼
* @param array $array Êý×é
* @return bool
*/
public function insert($array)
{
$fields = array();
$values = array();
foreach($array as $f => $v)
{
$fields[] = "`{$f}`";
$values[] = "'".mysql_real_escape_string($v)."'";
}
$fields = implode(',', $fields);
$values = implode(',', $values);
$sql = "INSERT INTO `{$this->table}`({$fields}) VALUES({$values})";
return $this->query($sql);
}
/**
* ¸üÐÂÒ»Ìõ¼Ç¼
* @param int $id Ö÷¼ü
* @param array $array Êý¾ÝÊý×é


Ïà¹ØÎĵµ£º

38ÌõPHP±àÂëÓÅ»¯¼ÓËÙ¼¼ÇÉ

1. ¾¡Á¿²ÉÓôóÁ¿µÄPHPÄÚÖú¯Êý¡£
2. echo ±È print ¿ì¡£
3. ²»Òª°Ñ·½·¨Ï¸·ÖµÃ¹ý¶à£¬×ÐϸÏëÏëÄãÕæÕý´òËãÖØÓõÄÊÇÄÄЩ´úÂ룿
4. ÔÚÖ´ÐÐforÑ­»·Ö®Ç°È·¶¨×î´óÑ­»·Êý£¬²»ÒªÃ¿Ñ­»·Ò»´Î¶¼¼ÆËã×î´óÖµ¡£
5. ×¢ÏúÄÇЩ²»ÓõıäÁ¿ÓÈÆäÊÇ´óÊý×飬ÒÔ±ãÊÍ·ÅÄÚ´æ¡£
6. ²¢·ÇÒªÓÃÀàʵÏÖËùÓеÄÊý¾Ý½á¹¹£¬Êý×éÒ²ºÜÓÐÓá£
7. $row['id']µÄÐ ......

PHPÃæÊÔÌâ»ã×Ü

»ù´¡Ìâ
¡¡¡¡1.±íµ¥ÖÐ getÓëpostÌá½»·½·¨µÄÇø±ð?
¡¡¡¡´ð£ºgetÓû§¶Ë½«Êý¾Ý¼Óµ½URLºó£¬¸ñʽΪ”?×Ö¶Î1=ÊäÈëÊý¾Ý1&×Ö¶Î2=ÊäÈëÊý¾Ý2&..."¡£
¡¡¡¡ÓÉÓÚgetÌá½»²ÎÊýºó»áÔÚµØÖ·À¸ÖÐÏÔʾ³öÀ´£¬ËùÒÔ»á²úÉúÑÏÖصݲȫÎÊÌâ¡£
¡¡¡¡get´«ÊäµÄÊý¾ÝÁ¿Ð¡£¬get´«ÊäµÄÊý¾ÝÁ¿Ð¡£¬ÕâÖ÷ÒªÊÇÒòΪÊÜurl³¤¶ÈÏÞÖÆ;¶øpost¿ÉÒÔ´«Ê ......

ÔõÑù²ÅÄܳÉΪPHP¸ßÊÖ£¿Ñ§»á"ÀÁ¶è"µÄ±à³Ì

      PHPÊÇһßßЧµÄÍøÂç±à³ÌÓïÑÔ£¬ÓÉÓÚËü¾ßÓбàдÁé»î¡¢ÔËÐпìËÙµÈÓŵ㣬ѸËÙ³ÉΪWeb³ÌÐòÔ±µÄÊ×Ñ¡ÓïÑÔ¡£Ç°²»¾ÃµÄÒ»·ÝȨÍþµ÷²é±íÃ÷£¬ÏÖÔÚÒѾ­ÓÐ31.6£¥µÄÍøվʹÓÃPHP×÷ΪÖ÷ÒªµÄ·þÎñÆ÷¶Ë±à³ÌÓïÑÔ¡£
¡¡¡¡µ«ÊÇ£¬Òª³ÉΪһÃûPHP±à³Ì¸ßÊÖÈ´²¢²»ÈÝÒס£²¢²»ÏñºÜ¶àÈËÏëÏóµÄÄÇÑù£¬Ö»ÒªÄܹ»·É¿ìµØ±àд ......

µÚÒ»Õ PHP¸ÅÊö (Öصã»Ø¹Ë)

1.PHPÊÇPHP: Hypertext PreprocessorµÄËõд,ÖÐÎÄÒëΪPHP:³¬Îı¾Ô¤´¦ÀíÆ÷.
2.PHPÊÇÒ»ÖÖ¼òµ¥µÄ,ÃæÏò¶ÔÏóµÄ,½âÊÍÐ͵Ä,½¡×³µÄ,°²È«µÄ,ÐÔÄܷdz£¸ßµÄ,¶ÀÁ¢Óڼܹ¹µÄ,¿ÉÒÆÖ²ÐÔµÄ,¶¯Ì¬µÄ·þÎñÆ÷¶Ë½Å±¾ÓïÑÔ.
3.PHP¾ßÓпçƽ̨ÐÔ,ÔÚ´ó¶àÊýUNIXƽ̨,Linuxƽ̨ºÍ΢ÈíWindowsƽ̨É϶¼¿ÉÒÔÔËÐÐ.
4.PHPÖ§³ÖJDBC,ÌṩMYSQL,Oracle,SybaseºÍM ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ