catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

Please join last_error() #425

Closed km3945 closed 3 years ago

km3945 commented 8 years ago

Please join

    public function last_error(){
        $error=$this->pdo->errorInfo();
        return (bool)$error[2];
    }

```php
                        $opts=['a1'=>'aaa','uid'=>3];
            $last_id=0;
            $this->db->action(function() use(&$opts, &$last_id) {
                $last_id = $this->db->insert("t_test", [
                    'f_items'    => $opts['a1'],
                    'f_uid'      => $opts['uid'],
                ]);
                $this->saveItems($opts['a1'], $last_id);
                $this->addLog($last_id, $opts['uid'], $opts['user'], $opts['ip'], $opts['message']);
                if($this->db->last_error()){
                    $last_id=0;
                    return false;
                }
            });
catfan commented 3 years ago

That will be improved on next v2.0.

https://github.com/catfan/Medoo/discussions/946