Post by BrunoMinervino » Tue Sep 12, 2017 9:35 pm

Hello,
I'm trying to use model function in external file, someone can help me?

Code: Select all

<?php

// Configuration
require_once('config.php');

// Startup
require_once(DIR_SYSTEM . 'startup.php');

// Registry
$registry = new Registry();

// Config
$config = new Config();
$config->load('default');
$registry->set('config', $config);

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
$registry->set('db', $db);

// Model
$model = $loader->model('checkout/order');
$model->addOrderHistory(1, 5, 'History test.', true);
Erros:
Fatal error: Uncaught Error: Call to a member function addOrderHistory() on null in C:\wamp64\www\opencart\test.php on line 27
Error: Call to a member function addOrderHistory() on null in C:\wamp64\www\opencart\test.php on line 27


Posts

Joined
Sun Jan 22, 2012 9:56 am

Post by straightlight » Tue Nov 14, 2017 10:07 am

Better to use this example for database API: viewtopic.php?f=128&t=172429&p=690535&h ... rt#p690535 . You can replicate pretty much every queries with this.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: Baidu [Spider] and 415 guests