lib csi composer project
Simple library for connecting database and create query builder model
version dev-master
* only support mysql/mariadb syntax, (*1)
It's recommended that you use Composer to install, (*2)
$ composer require libcsi/libcsi "dev-master"
OR, (*3)
{ "minimum-stability": "dev", "require": { "php": ">=5.3.0", "libcsi/libcsi": "dev-master" } }
composer install
<?php require_once 'vendor/autoload.php'; // put it somewhere you like $config = array ( 'DB' => array ( 'dbdriver' => 'mysql', 'dbserver' => 'localhost', 'dbname' => 'dbname', 'dbuser' => 'dbuser', 'dbpass' => 'dbpass' ) ); $db = new \CSI\Data\DataAdapter ( $config ["DB"] ); try{ // connect to database $db->connect(); }catch(\Exception $e){ die($e->getMessage()); }
<?php final class TableTest extends \CSI\Data\Model { // name of the table in database protected $table="table_test"; // name of primary key of this table protected $primaryKey="id"; }
$table = new TableTest(); $table->find("a primary key value"); $fieldvalue = $table->afiedname;
That's it, (*4)