Giter Site home page Giter Site logo

forko's Introduction

Work with Database in custom scripts via SMF and its forks

Install

composer require bugo/forko

Usage

// At first, require SSI.php of your forum (or autoload.php of your engine)
require_once(dirname(__FILE__) . '/SSI.php');

// Then require autoload.php from this package
require_once(__DIR__ . '/vendor/autoload.php');

// Define SMF
$name = 'smf';
$obj = $smcFunc;

// ... or Wedge
$name = 'wedge';
$obj = new wesql;

// ... or Elkarte
$name = 'elkarte';
$obj = database();

// ... or PortaMx
$name = 'pmx';
$obj = $pmxcFunc;

// ... or StoryBB
$name = 'sbb';
$obj = $smcFunc['db'];

// And now get the adapter
$forko = new \Bugo\Forko\Forko($name);
$adapter = '\Bugo\Forko\Adapters\\' . $forko->getAdapterName() . 'Adapter';
$db = new $adapter($obj);
// SELECT * FROM {db_prefix}topics
$all_topics = $db->findAll('topics');
var_dump($all_topics);
// INSERT INTO {db_prefix}calendar_holidays (event_date, title) VALUES('2020-01-01', 'The Event Name')
$result = $note_id = $db->insert('calendar_holidays', ['event_date' => 'string', 'title' => 'string'], ['2020-01-01', 'The Event Name'], ['id_holiday']);
var_dump($result);
// UPDATE FROM {db_prefix}topics SET title = "New title" WHERE id_topic = 1
$result = $db->update('topics', ['is_sticky' => '{int:is_sticky}'], 'WHERE id_topic = 1', ['is_sticky' => 1]);
var_dump($result);
// DELETE FROM {db_prefix}calendar_holidays WHERE id_holiday = $note_id
$result = $db->delete('calendar_holidays', 'WHERE id_holiday = {int:id}', ['id' => $note_id]);
var_dump($result);

forko's People

Contributors

dragomano avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.