Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedra/data
Config for Start PHP
https://github.com/pedra/data
Last synced: 11 days ago
JSON representation
Config for Start PHP
- Host: GitHub
- URL: https://github.com/pedra/data
- Owner: pedra
- Created: 2014-02-12T13:51:30.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-17T05:59:02.000Z (almost 11 years ago)
- Last Synced: 2024-11-27T23:11:57.474Z (2 months ago)
- Language: PHP
- Size: 215 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Config
======Config for Start PHP
[2014/01/30] add data base access point by PDO.
Examples
=**Composer install:**
Add this in your composer.json:
"require": {
"neos/data": "dev-master"
}
Now, type in terminal:$ composer update
**Optional condition to make things easier!**
*Type it in your index.php or bootstrap file:*
class_alias('Neos\Data\Config', 'o');
class_alias('Neos\Data\Conn', 'DB');
*Or, in class with namespaces, type (in top):*use Neos\Data\Config as o;
use Neos\Data\Conn as DB;**Configurations**
//loading config file
o::load('path/to/config.ini');*get and set config itens*
//simple get node
print_r(o::item());
//get item
print_r(o::get('item'));
//set new value
o::set('item', [mixed] value);
*saving the configuration file*o::save();
//or
o::save('path/to/copy/config.ini');**Data Base**
$value = 01;
$db = (new DB())->query('SELECT * FROM Table WHERE FielN = :value', ['value'=>$value]);
//Dump
print_r($db->getLine(0));
**Setting Alias for a connection database*****in Config.ini***
[db]
default = "dev";
dev[type] = "mysql";
dev[host] = "localhost";
dev[user] = "user";
dev[password] = "*******";
dev[database] = "database";
dev[charset] = "utf8";
other[type] = "sqlite";
other[database] = PPHP"app.db";***PHP script***
$db = new DB(); //connecting in a default database (dev)
//or
$db = DB('other'); //for connect in 'other' (sqlite)