|
|
|
@ -313,4 +313,47 @@ class Dm |
|
|
|
'pageData' => $pageData, |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
public function dmPDOFind($table,array $where) |
|
|
|
{ |
|
|
|
|
|
|
|
try { |
|
|
|
$database = config('database'); |
|
|
|
$dm_config = $database['connections']['dm']; |
|
|
|
|
|
|
|
$dsn = "dm:host={$dm_config['hostname']};port={$dm_config['hostport']};dbname={$dm_config['database']}"; |
|
|
|
|
|
|
|
$connection = new \PDO($dsn, $dm_config['username'], $dm_config['password']); |
|
|
|
$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
|
|
|
|
|
|
|
$tableName = $this->splitTableName($table); |
|
|
|
$fields = array_keys($where); |
|
|
|
|
|
|
|
$whereSqlArr = []; |
|
|
|
foreach ($fields as $field) $whereSqlArr[] = '"'.$field.'"' . ' = ' . '?'; |
|
|
|
|
|
|
|
$whereSql = implode(" and ",$whereSqlArr); |
|
|
|
|
|
|
|
$sql = "SELECT * FROM {$tableName} WHERE " . $whereSql; |
|
|
|
|
|
|
|
// 准备预编译语句 |
|
|
|
$statement = $connection->prepare($sql); |
|
|
|
|
|
|
|
$statement->bindParam(1, $where['user_name']); |
|
|
|
$statement->bindParam(2, $where['password']); |
|
|
|
|
|
|
|
// 执行查询 |
|
|
|
$statement->execute(); |
|
|
|
|
|
|
|
$data = []; |
|
|
|
while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { |
|
|
|
$data = $row; |
|
|
|
} |
|
|
|
if (empty($data)) return ['status' => false, 'msg' => '失败']; |
|
|
|
|
|
|
|
return ['status' => true, 'msg' => '成功','data' => $data]; |
|
|
|
} catch (\PDOException $e) { |
|
|
|
return ['status' => false, 'msg' => $e->getMessage()]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|