/home
/livrador
/public_html
/system
/models
/ORM.php
}
// --------------------- //
// --- MAGIC METHODS --- //
// --------------------- //
public function __unset($key) {
$this->offsetUnset($key);
}
public function offsetUnset($key) {
unset($this->_data[$key]);
unset($this->_dirty_fields[$key]);
}
public function __isset($key) {
return $this->offsetExists($key);
}
public function offsetExists($key) {
return array_key_exists($key, $this->_data);
}
/**
* Magic method to capture calls to undefined class methods.
* In this case we are attempting to convert camel case formatted
* methods into underscore formatted methods.
*
* This allows us to call ORM methods using camel case and remain
* backwards compatible.
*
* @param string $name
* @param array $arguments
*
* @return ORM
*/
public function __call($name, $arguments) {
$method = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name));
if(method_exists($this, $method)) {
/home
/livrador
/public_html
/system
/models
/ORM.php
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
class ORM implements ArrayAccess {
// ----------------------- //
// --- CLASS CONSTANTS --- //
// ----------------------- //
// WHERE and HAVING condition array keys
const CONDITION_FRAGMENT = 0;
const CONDITION_VALUES = 1;
const DEFAULT_CONNECTION = 'default';
// Limit clause style
const LIMIT_STYLE_TOP_N = "top";
const LIMIT_STYLE_LIMIT = "limit";
// ------------------------ //
// --- CLASS PROPERTIES --- //
// ------------------------ //
// Class configuration
/home
/livrador
/public_html
/system
/app.php
*/
if (APP_STAGE == 'Dev') {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
}
else {
error_reporting(0);
}
/*
|--------------------------------------------------------------------------
| ORM configuration (https://idiorm.readthedocs.io/en/latest/)
|--------------------------------------------------------------------------
|
*/
require __DIR__ . '/models/ORM.php';
ORM::configure('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME);
ORM::configure('username', DB_USER);
ORM::configure('password', DB_PASSWORD);
ORM::configure('driver_options', [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
ORM::configure('return_result_sets', true); // returns result sets
ORM::configure('logging', true);
/*
|--------------------------------------------------------------------------
| Smarty Init
|--------------------------------------------------------------------------
|
*/
$smarty = new Smarty();
// Set templates view
$smarty->setTemplateDir(
array(
APP_VIEW => APP_PATH . '/system/views/' . APP_VIEW . '/templates/',
'_default' => APP_PATH . '/system/views/_default/templates/'
/home
/livrador
/public_html
/index.php
<?php
require __DIR__ . '/system/app.php';