การใช้ ZF & Mysql กับ ภาษาไทย Zend Framework

หมวดสำหรับแบ่งบันความ รู้ต่างๆ จะมีหมวดย่อยๆ ในหมวดนี้ เช่น php, SQL, XML, CSS

Moderators: mindphp, ผู้ดูแลกระดาน

Post Reply
zend_framework
PHP Full Member
PHP Full Member
Posts: 41
Joined: 08/03/2011 11:22 pm

การใช้ ZF & Mysql กับ ภาษาไทย Zend Framework

Post by zend_framework » 17/04/2011 5:26 pm

การใช้ ZF & Mysql กับ ภาษาไทย Zend Framework

Code: Select all

class MyDb extends Zend_Db_Table
{
       protected $_name = 'mydb' ;
 
      function MySearch($mytable1, $mysearch)
       {
         $config = new Zend_Config_Ini('../application/config.ini', 'general');
         $db = new Zend_Db_Adapter_Pdo_Mysql(array(
                       'host'     => $config->db->params->host ,
                        'username' => $config->db->params->username,
                        'password' => $config->db->params->password,
                        'dbname'   =>$config->db->params->dbname,
                       'driver_options'  => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'tis620\'')
                       ));

               $sql = "SELECT * FROM  $mytable1 WHERE studentid='$mysearch' ";
               $result = $db->fetchAll($sql, 2);
       return $result ;
       }//end_func_Search

}



    function insertdata($mytable, $data)
    {
      $config = new Zend_Config_Ini('../application/config.ini', general);
      $db = new Zend_Db_Adapter_Pdo_Mysql(array(
                'host'     => $config->db->params->host ,
                'username' => $config->db->params->username,
                'password' => $config->db->params->password,
                'dbname'   =>$config->db->params->dbname,
                'driver_options'  => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'tis620\'')
     ));
        $n = $db->insert($mytable, $data);
        return $n ; // 1 success , 0 fail;

    }//end_insert_items


    function deletedata($mytable, $where)
    {
      $config = new Zend_Config_Ini('../application/config.ini', 'general');
      $db = new Zend_Db_Adapter_Pdo_Mysql(array(
                'host'     => $config->db->params->host ,
                'username' => $config->db->params->username,
                'password' => $config->db->params->password,
                'dbname'   =>$config->db->params->dbname,
                'driver_options'  => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'tis620\'')
     ));
        $n = $db->delete($mytable, $where);

        return $n ; // 1 success , 0 fail;

    }//end_func_updatecatagory


    function update($mytable, $data, $where)
    {
      $config = new Zend_Config_Ini('../application/config.ini', 'general');
      $db = new Zend_Db_Adapter_Pdo_Mysql(array(
                'host'     => $config->db->params->host ,
                'username' => $config->db->params->username,
                'password' => $config->db->params->password,
                'dbname'   =>$config->db->params->dbname,
                'driver_options'  => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'tis620\'')
     ));
        $n = $db->update($data, $where);

        return $n ; // 1 success , 0 fail;

    }//end_func_updatecatagory



 

Post Reply

Return to “Share Knowledge”

Users browsing this forum: facebook.com [Crawler] and 29 guests