/** * @depends testInsertContact */ public function testQuery($contact) { $user = new User(); $user->isnotnull('id')->eq('id', 1)->lt('id', 2)->gt('id', 0)->find(); $this->assertGreaterThan(0, $user->id); $this->assertSame(array(), $user->dirty); $user->name = 'testname'; $this->assertSame(array('name' => 'testname'), $user->dirty); $name = $user->name; $this->assertEquals('testname', $name); unset($user->name); $this->assertSame(array(), $user->dirty); $user->reset()->isnotnull('id')->eq('id', 'aaa"')->wrap()->lt('id', 2)->gt('id', 0)->wrap('OR')->find(); $this->assertGreaterThan(0, $user->id); $user->reset()->isnotnull('id')->between('id', array(0, 2))->find(); $this->assertGreaterThan(0, $user->id); }
require_once dirname(__FILE__) . '/../../YDFramework2/YDF2_init.php'; YDConfig::set('YD_DATABASEOBJECT_PATH', YD_SELF_DIR . YD_DIRDELIM . 'includes'); YDInclude('User.php'); $user = new User(); // Let's truncate the table first $user->executeSql('TRUNCATE ' . $user->getTable()); // Let's begin echo "<h1>Let's add some Users</h1>"; $user->name = 'David Bittencourt'; $user->email = '*****@*****.**'; $user->is_admin = 1; $user->birthday = '19801120'; $user->insert(); YDDebugUtil::dump($user->getValues()); echo '<p>The user "' . $user->name . '" have ID = ' . $user->id . '.</p>'; $user->reset(); $user->name = 'Pieter Claerhout'; $user->email = '*****@*****.**'; $user->is_admin = 1; $user->birthday = null; // we can have null values if we set the field correctly $user->insert(); YDDebugUtil::dump($user->getValues()); echo '<p>The user "' . $user->name . '" have ID = ' . $user->id . '.</p>'; $user->reset(); $user->name = 'Francisco'; $user->email = '*****@*****.**'; $user->birthday = null; $user->insert(); YDDebugUtil::dump($user->getValues()); echo '<p>The user "' . $user->name . '" have ID = ' . $user->id . '.</p>';
$contact = new Contact(); $contact->address = 'test'; $contact->email = '*****@*****.**'; $contact->user_id = $user->id; var_dump($contact->insert()); $contact = new Contact(); $contact->address = 'test'; $contact->email = '*****@*****.**'; $contact->user_id = $user->id; var_dump($contact->insert()); var_dump($user->contact); echo "\n -----"; var_dump($user); echo "\n join\n"; $contact = new Contact(); var_dump($contact->select('user.*, contact.*')->join('user', 'user.id = contact.user_id')->find()); /* $contact = new Contact(); $contact->address = 'test'; $contact->email = '*****@*****.**'; $contact->user_id = 2; var_dump($contact->insert()); */ $user = new User(); var_dump($user->select('user.*, c.email, c.address')->join('contact as c', 'c.user_id = user.id')->findAll()); var_dump($user->reset()->notnull('id')->orderby('id desc')->find()); echo "\nContact of User # {$user->id}\n"; var_dump($user->contacts); $contact = new Contact(); var_dump($contact->find()); var_dump($contact->user);
$input->digits($delete, 'Deletion ID of User'); if ($users->delete($delete)) { flash("User (" . $delete . ") Deleted Successfully"); } else { throw new Exception("The specified user could not be removed."); } } if ($unlock) { // Unlock the user $updateUser = new User(); $input->digits($unlock, 'Unlock ID of User'); $updateUser->id = $unlock; $updateUser->failed = 0; if ($updateUser->save()) { flash("User failed logins count reset."); } $updateUser->reset(); } $users->load_all(); include "../views/manageusers.php"; } catch (LoginException $e) { $redirect = "manageusers.php"; include "../views/login.php"; throw $e; } catch (InputException $e) { include "../views/manageusers.php"; throw $e; } catch (Exception $e) { include "../views/manageusers.php"; throw $e; }