Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum (1) | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 168 | All time: 8,833 This week: 149![]() |
Version | License | PHP version | Categories | |||
lmsql 1.2 | MIT/X Consortium ... | 5 | PHP 5, Databases |
Description | Author | |
This class can connect and perform MySQL database queries. |
LMSQL is a simple MySQL class that uses PDO. With LMSQL you don't need to write a lot of code to get results from a table and it's very easy to use.
require_once('mysql.class.php');
$mysql = new LMSQL('localhost', 'root', '123456', 'databaseName', true);
or
$mysql = new LMSQL('localhost', 'root', '123456', 'databaseName');
$mysql->connect();
default charset is utf8.
Get data from table with where clause, limit, order and custom index
@return array
Simple usage
$data = $mysql->select(['table'=>'news']);
With fields, where clause, order and limit.
$data = $mysql->select([
'table'=>'tableName',
'fields'=>'id, title, body',
'where'=>['category'=>'news'],
'order'=>'id DESC',
'limit'=>10
]);
With custom array index
$data = $mysql->select([
'table'=>'tableName',
'index'=>['column'=>'type', 'multi'=>true]
]);
With custom SQL
$data = $mysql->select(["sql"=>"SELECT news_title FROM news, category WHERE news_category = category_id and category_type = 'active'"]);
Get one row from table
@return array
$data = $mysql->load(['table'=>'news', 'where'=>'id = 1']);
Insert data to table
$mysql->insert(['table'=>'users', 'values'=>['fullname'=>'Arash', 'company'=>'Leomoon']]);
Update rows
$mysql->update(['table'=>'users', 'where'=>['id'=>2218], 'values'=>['name'=>'Amin']]);
Delete rows
$mysql->delete(['table'=>'tableName', 'where'=>['id', '817']]);
Get total rows
@return int
$mysql->total(['table'=>'tableName', 'where'=>'id > 5']);
or
$mysql->count(['table'=>'tableName', 'where'=>['status'=>'active', 'category'=>'something']]);
Get the last inserted id
$mysql->insertId();
Search in all fields
$mysql->search([
'table'=>'news',
'word'=>'%fake%'
]);
Search in specific fields
$mysql->search([
'table'=>'news',
'word'=>'%fake%',
'searchs'=>['title']
]);
Show tables of current DB:
$mysql->schema();
Show columns:
$mysql->schema(['table'=>'YourTableName']);
Execute your custom sql query
$mysql->exec($sql);
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Lic. | License text | ||
![]() |
Class | Class source | ||
![]() ![]() |
Doc. | Documentation |
![]() |
/ | .github | / | ISSUE_TEMPLATE |
File | Role | Description |
---|---|---|
![]() ![]() |
Data | Auxiliary data |
![]() ![]() |
Data | Auxiliary data |
![]() |
/ | demo |
File | Role | Description |
---|---|---|
![]() ![]() |
Example | insert example |
![]() ![]() |
Example | update example |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.