Skip to content

Instantly share code, notes, and snippets.

View alfrekjv's full-sized avatar

Alfredo Juárez alfrekjv

View GitHub Profile
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var domStyle = document.createElement("style");
domStyle.append(
'* { color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }\
* * { background-color: rgba(0,255,0,.2) !important; }\
* * * { background-color: rgba(0,0,255,.2) !important; }\
* * * * { background-color: rgba(255,0,255,.2) !important; }\
* * * * * { background-color: rgba(0,255,255,.2) !important; }\
@elliette
elliette / ManyToManyRelationships.md
Last active October 31, 2023 16:03
Describing `belongsToMany` and `hasMany` methods in Sequelize

Defining Many-to-Many Associations in Sequelize

Reference: Sequelize docs on association

Let’s say we have two models: Films and Festivals

We know that a film can be shown at many film festivals and that, conversely, a festival can show many films. This is what is known as a many-to-many relationship.

Knowing this, we can set up our associations:

<?php
class APP_Model_CategoryNew {
protected $_name = 'category';
protected $_key = 'id';
function __construct() {
$ds = new PPI_DataSource();
$this->_handler = $ds->factory('mysql');
}
<?php
class APP_Controller_Test extends APP_Controller_Application {
function index() {
$model = new APP_Model_Test();
$rows = $model->getAllRows();
$data = array('foo' => 'bar', 'user' => 'ppi_user');
$newID = $model->addRow($data);
$this->redirect('user/profile/' . $newID);