diff --git a/App/Controllers/DocComment.php b/App/Controllers/DocComment.php index 3b19612..b3e9d2c 100644 --- a/App/Controllers/DocComment.php +++ b/App/Controllers/DocComment.php @@ -12,22 +12,12 @@ use App\Config; class DocComment extends Controller { public function insertAction(){ - $user = new Models\User(); + $comment = new Models\DocComment(); date_default_timezone_set("Asia/Shanghai"); - //var_dump($this->input); + var_dump($this->input); $userdate = date("Y-m-d H:i:s",time()); - $this->input->created_date = $userdate; - $this->input->update_date = $userdate; - if( strlen($this->input->user_pwd ) < 6){ - $this->JsonResp(201,null,"password empty"); - return; - } - if(!$this->is_password($this->input->user_pwd)){ - $this->JsonResp(201,null,"password illegal"); - return; - } - $all = $user->InsertObject($this->input); - $this->JsonResp(200,$all,"OK"); + $comment->InsertObject($this->input); + //$this->JsonResp(200,$all,"OK"); } } \ No newline at end of file diff --git a/App/Models/DocComment.php b/App/Models/DocComment.php index 3a56488..be6c079 100644 --- a/App/Models/DocComment.php +++ b/App/Models/DocComment.php @@ -8,5 +8,9 @@ use PDO; class DocComment extends Model { - + public $tableName = 'doc_comment'; + function InsertObject($obj) + { + return parent::InsertObject($obj); // TODO: Change the autogenerated stub + } } \ No newline at end of file diff --git a/App/Models/User.php b/App/Models/User.php index 0b0ccbc..49103d7 100644 --- a/App/Models/User.php +++ b/App/Models/User.php @@ -23,27 +23,10 @@ class User extends \Core\Model $stmt = $db->query('SELECT * FROM users'); return $stmt->fetchAll(PDO::FETCH_ASSOC); } - public function Insert($user){ + public function Insert($comment){ $db = static::getDB(); - $stmt = $db->query(`insert into users('user_name','user_pwd','create_date','update_date','display_name' - ,'email_address','tel','avatar') values (` + $user["user_name"] + `,` + - $user["user_pwd"] + `,` + - $user["create_date"] + `,` + - $user["update_date"] + `,` + - $user["display_name"] + `,` + - $user["email_address"] + `,` + - $user["tel"] + `,` + - $user["avatar"] + `,` + - + `)` + `ON DUPLICATE KEY UPDATE users.user_name = ` + $user["user_pwd"] + `,` + - `users.user_pwd = ` +$user["user_pwd"] + `,` + - `users.create_date = ` +$user["create_date"] + `,` + - `users.update_date = ` +$user["update_date"] + `,` + - `users.display_name = ` +$user["display_name"] + `,` + - `users.email_address = ` +$user["email_address"] + `,` + - `users.tel = ` +$user["tel"] + `,` + - `users.avatar = ` +$user["avatar"] + `,` + $stmt = $db->query(`insert into doc_comment('doc_id','child_id','content','time'') values (` + $comment["doc_id"] + `,` + $comment["child_id"] + `,` + $comment["content"] + `,` + $comment["time"] + `;` ); return $stmt->fetchAll(PDO::FETCH_ASSOC); } - } diff --git a/App/Views/blog/basic.html b/App/Views/blog/basic.html index 7440ba9..13b6767 100644 --- a/App/Views/blog/basic.html +++ b/App/Views/blog/basic.html @@ -248,7 +248,6 @@ ul li a{ updateMenu(); firstinit = true; }else{ - console.log("first init pass"); } console.log($("#doc_type_{{type}}").innerText); $("#doc_type_{{type}}").addClass("active"); diff --git a/Core/Model.php b/Core/Model.php index 837229f..0116a54 100644 --- a/Core/Model.php +++ b/Core/Model.php @@ -95,9 +95,10 @@ abstract class Model $query = $query.$val; $stmt = $db->query($query); - - $res = $stmt->fectchAll(); + var_dump($stmt); + print_r($stmt->errorInfo()); + //$res = $stmt->fetch(); //$result = $stmt->fetchAll(); - return $res; + //return $res; } }