function requestToken() { $token = md5(uniqid(mt_rand(), true)); if (!$this->user) { return null; } $table = new JS_Table('users'); if ($table->store(array('ID' => $this->user->ID, 'token' => $token))) { $this->user->token = $token; return $token; } return null; }
function create_db_table() { $tables = array('jobs_relationships' => array(array('field' => 'id', 'type' => 'int(11)', 'null' => false, 'extra' => 'auto_increment', 'default' => null, 'key' => 'PRI'), array('field' => 'job_id', 'type' => 'int(11)', 'null' => false, 'extra' => null, 'default' => null, 'key' => null), array('field' => 'applicant_id', 'type' => 'int(11)', 'null' => false, 'extra' => null, 'default' => null, 'key' => null), array('field' => 'jobsboss_id', 'type' => 'int(11)', 'null' => true, 'extra' => null, 'default' => null, 'key' => null), array('field' => 'snap_date', 'type' => 'datetime', 'null' => false, 'extra' => null, 'default' => '0000-00-00 00:00:00', 'key' => null), array('field' => 'snap_status', 'type' => 'varchar(50)', 'null' => false, 'extra' => null, 'default' => 'pending', 'key' => null), array('field' => 'timesnap_id', 'type' => 'int(11)', 'null' => true, 'extra' => null, 'default' => null, 'key' => null))); foreach ($tables as $table_name => $columns) { $table_object = new JS_Table($table_name); foreach ($columns as $column) { $table_object->add_column($column); $table_object->render_table(); } } }