Medoo Getting Started: Installing and configuring-medoo usage Guide

Source: Internet
Author: User
Tags php language mssql php database
What is Medoo? The lightest PHP database framework to accelerate development! Accelerate the development of the lightest PHP database framework! Medoo's powerful and sophisticated API not only fits your most basic needs, but is also very simple to use. Even if you have to develop two times, there is no problem. The first translation is Medoo's introductory article, first of all to talk about the installation and configuration of Medoo.

What is Medoo? Look at what the official wrote:

The lightest PHP database framework to accelerate development!  speed up the development of the lightest PHP database framework!

Medoo slogan or shout loudly, actually whether really good? After a period of use, I found that Medoo really, as the official introduction, can greatly speed up the development of your PHP project. In web development, a large part of the enterprise or individual will choose to use the PHP language, and Medoo can play a icing on the cake. Shorten your development cycle. Medoo's powerful and sophisticated API not only fits your most basic needs, but is also very simple to use. Even if you have to develop two times, there is no problem. Even so, Chinese documents on the Web are not perfect. So I decided to translate and sort the medoo myself. may not be very accurate, but still want to do not miss the official message on the basis of the meaning, as far as possible to be understandable. Well, let's start with the introductory article.

Entry

It's so easy to use Medoo!

Demand

Must be PHP 5.1 or more, very, very special, extremely, highly recommended: Use PHP 5.4 or later and turn on PDO support. You can install databases such as Mysql,mssql,sqlite, or more. Make sure that php_pdo_xxx (xxx = The name of the database you want to use) extension is installed and enabled in PHP.ini. I think you might need a little bit of SQL basics. (as a developer, I don't think it's a problem ^^!)

Warm tips

For PHP 5.4+, you can use [] as an abbreviated syntax for an array. All Medoo sample code uses [] to replace array ().

PHP 5.1 var data = array ("foo", "Bar");//php 5.4+ var data = ["foo", "Bar"];

Installation

Just download the medoo.php and put it in the correct directory, and everything is OK!

Configuration

There are two ways to configure Medoo and start a database connection.

1. Independent configuration method require ' medoo.php '; $database = new Medoo ([//Required ' database_type ' = ' mysql ', ' database_name ' = ' name ') , ' server ' = ' localhost ', ' username ' = ' your_username ', ' password ' = ' your_password ',//optional ' port ' = 3306, ' CharSet ' = ' utf8 ',//DB connection Drive option, learn more http://www.php.net/manual/en/pdo.setattribute.php ' option ' and [pdo::attr_ case = pdo::case_natural]]); $database->insert ("Account", ["user_name" + "foo", "email" = "foo@bar.com"] );//2. Open medoo.php directly and edit some configuration information at the top of the file,//and then use it directly after you do not have to configure it again. MySQL, MSSQL, PostgreSQL, Sybase type names are as follows://MySQL---mysql//MSSQL, mssql//PostgreSQL, pgsql//Sybase-&gt ; Sybaseclass medoo{protected $database _type = ' mysql ';//DB type name protected $server = ' localhost ';p rotected $username = ' Your _username ';p rotected $password = ' your_password ';//optional protected $port = 3306;protected $charset = ' UTF8 '; OK, now everything is ready.!require_once ' medoo.php '; $database = new Medoo (' my_database '); $database->insert ("account", ["user_name" + "foo", "email" = "foo@bar.com"]); 

For SQLite

For MSSQL if you want to use MSSQL with Medoo under the PHP platform, you need to install the pdo_sqlsrv PHP extension in a Windows environment, or install the pdo_dblib PHP extension in a Liunx/unix environment. The pdo_mssql extension has been revoked and will soon be removed from PHP.

1. Although the DB type name in the edit medoo.php file is class medoo{protected $database _type = ' sqlite ';//For SQLite [optional]protected $database _file = ' my/database/path/database.db '; OK, now everything is ready.!require_once ' medoo.php '; $database = new Medoo (' my/database/path/database.db ');//2. Or stand-alone configuration $database = new Medoo ([' database_type ' = ' sqlite ', ' database_file ' = ' my/database/path/database.db ']); Database->insert ("Account", ["user_name" = "foo", "email" = "foo@bar.com"]);

Installation of the PDO driver in PHP

Medoo need to use the PDO extension of PHP. If you have not previously installed, follow these steps.

Open the PHP installation directory under the php.ini file, locate the following line and turn the semicolon '; ' Remove. Other types of databases should be removed separately. Remove '; ' before; extension=php_pdo_mysql.dll//remove '; ' after extension=php_pdo_mysql.dll//then save and restart Apache server//If the installation is successful, you can Phpinfo () sees information about the PDO extension.

OK, now it's finally easy to get the db operation frame in place. Isn't it very simple. ^^!

  • 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.