About my PHP framework, how to use the database tier

Source: Internet
Author: User

Framework, the database contains two tiers, one zz_db.php, and one zz_model.php

Use:

Project portal Definition Database parameters:

Mysql
Define (' Zz_mysql_host ', ' 127.0.0.1 ');
Define (' Zz_mysql_user ', ' root ');
Define (' ZZ_MYSQL_PW ', ');
Define (' zz_mysql_db ', ' microblog_home '); Only one database operation is temporarily available
Define (' Zz_mysql_table_pre ', ' mh_ ');

Build yourself in the project's model layer, for example: Usermodel.php extends zz_model.php

See zz_model.php for the parameters required for each method and the results returned.

Database Operation methods:

Increase:

$array = Array (
' Username ' = ' 123456789 ',
' Password ' = ' TTT ',
' Reg_time ' = Time (),
);

$result = $this->insert ($array);

Check: (Multiple data)

(Returns a two-dimensional array or null)

$field = Array (' username ', ' password ');
$option = Array (
' id ' = ' [<] '. $a,
' [or]username ' = ' Alazalaz ',
' Password ' = ' [>=]ssss ',
' [or]mail ' = ' xxx ',
);
$this->select ($field, $option, 7);

Select Username,password from Mh_user where id< ' 2222 ' or username= ' Alazalaz ' and password>= ' ssss ' or mail= ' xxx ' 
    
     limit 7
    

Check: (a piece of data)

Ditto (but returns an array or empty)

$this->select_one ($field, $option, 7);

Change:

$field = Array (' state ' =>1);

$option = array (' id ' = ' 2 ');

$this->update ($field, $option);

About my PHP framework, how to use the database tier

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.