8000 update with column has restracted word · Issue #21 · InitPHP/Database · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
update with column has restracted word #21
Open
@andaroid

Description

@andaroid
use \InitPHP\Database\Facade\DB;
$data = [
    'title'     => 'New Title',
    'order'     => '1',
'content'   => 'New Content',
];

$isUpdate = DB::from('post')
                ->where('id', 13)
                ->update($data);
    
/**
* This execute
5421
s the following query.
* 
* UPDATE post 
* SET title = "New Title", content = "New Content"
* WHERE id = 13
*/
if ($isUpdate) {
    // Success
} else {
    $errors = DB::getError();
    foreach ($errors as $errMsg) {
        echo $errMsg;
    }
}

Firstly thanks for nice library :D and please keep good updating of it

this code above will give error
Fatal error: Uncaught InitPHP\Database\Exceptions\SQLQueryExecuteException: SQLSTATE[42000]: Syntax error or access violation: 1064 You
have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = 1

the problem is column "order" is restracted in mysql and must escaped with ``
how to do that with update function ??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0