Fixes for MySQL driver
This commit is contained in:
parent
9a9220ab24
commit
8cfc2aeb2a
3 changed files with 13 additions and 7 deletions
|
@ -15,6 +15,7 @@ class Database
|
|||
self::$pdo = new PDO($dsn, $user, $pass);
|
||||
self::$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
self::$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
self::$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
@ -53,7 +54,14 @@ class Database
|
|||
if (!self::connected())
|
||||
throw new Exception('Database is not connected');
|
||||
$statement = self::makeStatement($sqlQuery);
|
||||
try
|
||||
{
|
||||
$statement->execute();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('Problem with ' . $sqlQuery->getSql() . ' (' . $e->getMessage() . ')');
|
||||
}
|
||||
self::$queries []= $sqlQuery;
|
||||
return $statement;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,8 @@ class PostEntity extends AbstractEntity
|
|||
->select('post.*')
|
||||
->from('post')
|
||||
->innerJoin('crossref')
|
||||
->on()->open()->raw('post.id = crossref.post2_id')->and('crossref.post_id = :id')->close()
|
||||
->or()->open()->raw('post.id = crossref.post_id')->and('crossref.post2_id = :id')->close()
|
||||
->put(['id' => $this->id]);
|
||||
->on()->open()->raw('post.id = crossref.post2_id')->and('crossref.post_id = ?')->close()->put($this->id)
|
||||
->or()->open()->raw('post.id = crossref.post_id')->and('crossref.post2_id = ?')->close()->put($this->id);
|
||||
$rows = Database::fetchAll($query);
|
||||
$posts = PostModel::convertRows($rows);
|
||||
$this->setCache('relations', $posts);
|
||||
|
|
|
@ -104,9 +104,8 @@ class UserModel extends AbstractCrudModel
|
|||
$query = new SqlQuery();
|
||||
$query->select('*')
|
||||
->from('user')
|
||||
->where('LOWER(name) = LOWER(:user)')
|
||||
->or('LOWER(email_confirmed) = LOWER(:user)')
|
||||
->put(['user' => trim($key)]);
|
||||
->where('LOWER(name) = LOWER(?)')->put(trim($key))
|
||||
->or('LOWER(email_confirmed) = LOWER(?)')->put(trim($key));
|
||||
|
||||
$row = Database::fetchOne($query);
|
||||
if ($row)
|
||||
|
|
Loading…
Reference in a new issue