Example #1
0
 function test_insert()
 {
     $query = DB::factory()->for_table('test');
     $query->name = 'test';
     $query->save();
     echo json_encode(array('query' => $query->get_query(), 'result' => $query->as_array(), 'query2' => $query->get_query()), JSON_NUMERIC_CHECK);
 }
Example #2
0
 function test_model_2()
 {
     $result = DB::factory()->for_table('test')->find_one();
     $result = Model_Test_2::factory()->where_id_is($result->id())->find_one();
     $this->assertArrayHasKey('id', $result->as_array());
     echo json_encode(array('result' => $result->as_array(), 'query' => $result->get_query()), JSON_NUMERIC_CHECK);
 }
Example #3
0
 function test_update_resultset()
 {
     $data = array();
     $result = DB::factory()->for_table('test')->where_like('name', '4ed%')->limit(3)->find_many();
     $data['before_data'] = $result->as_array();
     $data['query'] = $result->get_query();
     $result->name = uniqid();
     $result->save();
     $data['method_queries'] = $result->get_queries();
     $data['after_data'] = $result->as_array();
     echo json_encode($data, JSON_NUMERIC_CHECK);
 }
Example #4
0
 /**
  * Constructor
  *
  * @return  $this
  */
 public function __construct($id = NULL, $config = NULL, $orm = NULL)
 {
     // Detect DB ID to use
     if ($id == NULL and $this->db_id != NULL) {
         $id = $this->db_id;
     }
     $this->db_id = $id;
     $this->config = $config;
     $table_name = $this->_get_table_name();
     // Initiate ORM
     if ($orm == NULL) {
         $this->orm = DB::factory($id, $config);
         $this->orm->table($table_name);
     } else {
         $this->orm = $orm;
     }
     $this->prepare_fields();
     return $this;
 }
Example #5
0
 function test_select_query_blacklist()
 {
     $this->set_testing_rules_wildcard();
     ACL::set_actor(\CrossORM\ACTOR_DEFAULT, \CrossORM\MODE_BLACKLIST);
     $rules = ACL::get_rules();
     $actor = ACL::get_actor();
     try {
         $result = DB::factory()->acl()->for_table('test')->find_one();
         $this->fail('ACL should cause failure');
     } catch (\CrossORM\Exceptions\ACL $e) {
         echo json_encode(array('rules' => $rules, 'flat' => ACL::get_rules(true), 'actor' => $actor, 'result' => stripslashes(json_encode($e))), JSON_NUMERIC_CHECK);
     }
 }
Example #6
0
<?php

$ds = DIRECTORY_SEPARATOR;
$up = '..' . $ds;
if (!defined('BASEDIR')) {
    define('BASEDIR', realpath(dirname(__FILE__) . $ds . $up . $up . 'library') . $ds);
}
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Autoloader.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Models.php';
\CrossORM\DB::factory(array('driver' => 'PDO', 'connection_string' => 'sqlite:' . dirname(__FILE__) . $ds . 'testing.db'));
Example #7
0
 function test_delete()
 {
     $query = DB::factory()->for_table('test')->find_one();
     echo json_encode(array('query' => $query->get_query(), 'result' => $query->as_array(), 'delete' => $query->delete(), 'query2' => $query->get_query()), JSON_NUMERIC_CHECK);
 }