PHP code example of jimwins / titi
1. Go to this page and download the library: Download jimwins/titi library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jimwins / titi example snippets
use \Titi\ORM;
use \Titi\Model;
$user = ORM::for_table('user')
->where_equal('username', 'j4mie')
->find_one();
$user->first_name = 'Jamie';
$user->save();
$tweets = ORM::for_table('tweet')
->select('tweet.*')
->join('user', array(
'user.id', '=', 'tweet.user_id'
))
->where_equal('user.username', 'j4mie')
->find_many();
foreach ($tweets as $tweet) {
echo $tweet->text;
}
/* ActiveRecord model */
class User extends Model {
public function tweets() {
return $this->has_many('Tweet');
}
}
class Tweet extends Model {}
$user = Model::factory('User')
->where_equal('username', 'j4mie')
->find_one();
$user->first_name = 'Jamie';
$user->save();
$tweets = $user->tweets()->find_many();
foreach ($tweets as $tweet) {
echo $tweet->text;
}