Esempio n. 1
0
<?php

use Onephile\Model;
$Model = Model::make('model_test_1');
$results = $Model->select(array('where' => "`email`='%s' OR id=%d", 'args' => array('*****@*****.**', 3)));
// expecting result as array
foreach ($results as $v) {
    // fmt() runs value thru htmlentities by default (& => &amp);
    echo implode("\n", array('ID: ' . $v->fmt('id'), 'Name: ' . $v->fmt('name'), 'Email: ' . $v->fmt('email'))) . "\n\n";
}
Esempio n. 2
0
<?php

use Onephile\Model;
$result = Model::make('model_test_1')->insertArray(array(array('name' => 'Example & Sons', 'email' => '*****@*****.**'), array('name' => 'Example & Sons, Inc.', 'email' => '*****@*****.**'), array('name' => 'Another Company', 'email' => '*****@*****.**')));
var_dump($result);
Esempio n. 3
0
<?php

use Onephile\Model;
$ModelWithId = Model::make('model_test_1', $new_id);
var_dump($ModelWithId->id);
var_dump($ModelWithId->name);
Esempio n. 4
0
 /**
  * update
  */
 public function testUpdate()
 {
     $data = array('name' => 'new name 1');
     // no id sent to update
     $Test = Model::make(self::$table1);
     $r = $Test->update($data);
     $this->assertFalse($r);
     // id sent
     $id = 1;
     $r = $Test->update($data, $id);
     $this->assertEquals($id, $r);
     // load model with $id
     $Test = Model::make(self::$table1, $id);
     $r = $Test->update($data);
     $this->assertEquals($id, $r);
     // update again with refresh on model
     $data['name'] = 'new name one';
     $r = $Test->update($data, true);
     $this->assertEquals($id, $r);
     $this->assertEquals($data['name'], $Test->val('name'));
 }