pdo

Dokku deployed Silex can't find PdoServiceProvider

核能气质少年 提交于 2019-12-24 12:08:28
问题 I have a project done with Silex, and I was using herrera-io/silex-pdo as the PDO provider, but I faced random crashes with socket errors (I connect to the DB via socket), since that lib is abandoned, I changed to csanquer/pdo-service-provider , and it works just fine on my localhost server, but when I deploy to remote, I get the following error: PHP Fatal error: Class 'Csanquer\Silex\PdoServiceProvider\Provider\PdoServiceProvider' not found in /app/web/index.php on line 52 Here is the code

Multiple inserts not working with SQLite 3

那年仲夏 提交于 2019-12-24 12:05:03
问题 The specific error, using a SQLite DB with PDO in PHP: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near ",": syntax error' in D:\Projects\2013\Stat collection plugin\stats\htdocs\index.php:8 Stack trace: #0 D:\Projects\2013\Stat collection plugin\stats\htdocs\index.php(8): PDO->exec('CREATE TABLE IF...') #1 {main} thrown in D:\Projects\2013\Stat collection plugin\stats\htdocs\index.php on line 8 The code: $dbSchema = file_get_contents('..

SQL connection error from PHP after many operations

烂漫一生 提交于 2019-12-24 11:36:03
问题 I'm currently looping to create a MBTiles map, and add information to my database each time. Here's how I configured my connection and execute actions during the loop: if ($pdo_mbtiles == null) { echo "Opening new database connection".PHP_EOL; $pdo_mbtiles = new PDO('sqlite:'.$filename, '', '', array( PDO::ATTR_PERSISTENT => true ) ); $pdo_mbtiles->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $pdo_mbtiles->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } $q = $pdo

Return multiple row without the use of mysqlnd

こ雲淡風輕ζ 提交于 2019-12-24 11:35:42
问题 I dont have mysqlnd available, so i implemented a helper function to do the job: public function bind_array($stmt, &$row) { $md = $stmt->result_metadata(); var_dump($md); $params = array(); while($field = $md->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($stmt, 'bind_result'), $params); } The trouble is, that i also need it to be able to return multiple rows. As of now it can only return a single row. Thanks.... EDIT: What im aiming for is getting the same

Combining two SQL queries PDO

余生颓废 提交于 2019-12-24 11:32:56
问题 I'm quite stuck on the following issue. I have a series of tables: What I want to do is get all the information on a room, assuming that the amount of bookings don't exceed the room number available for that Room. So to get my Room details my SQL is this: SELECT Rooms.RoomID as RoomID, RoomName, NumOfRooms, MaxPeopleExistingBeds, MaxExtraBeds, MaxExtraPeople, CostPerExtraPerson, MaximumFreeChildren, IncludeBreakfast, MinRate FROM Rooms, RoomDetails WHERE Rooms.AccommodationID = :aid AND Rooms

Error matching dates in PDO

这一生的挚爱 提交于 2019-12-24 11:29:38
问题 I am trying to update records on a database table where the date column matches the present year and month. I keep getting this error Incorrect datetime value: '%2018-06%' for column 'created_at' This is what I am doing $current_month = date("Y-m"); $points = 4; $freelancer_id =4; $update = "UPDATE monthly_limits SET points = :points WHERE freelancer_id = :freelancer_id AND created_at LIKE concat('%', :current_month, '%')"; $query = $this->db->prepare($update); $query->bindParam("points",

PDO and SQL IN statements [duplicate]

孤者浪人 提交于 2019-12-24 10:59:48
问题 This question already has answers here : Can I bind an array to an IN() condition? (21 answers) Closed 6 years ago . Im using a sequel for search like this using PDOs $states = "'SC','SD'"; $sql = "select * from mytable where states in (:states)"; $params = array(':states'=>$states); and I use my function $result = $this->selectArrayAssoc($sql, $params); where my selectArrayAssoc function as following public function selectArrayAssoc($sql, $params = array()) { try { $sth = $this->db->prepare(

multiple INSERTS and keeping PDO prepared statement security

大兔子大兔子 提交于 2019-12-24 10:47:36
问题 I have the following piece of code which sends to each member of mya_users a mail (this is what INSERT into inbox does. $query_write_mass = "SELECT id FROM mya_users ORDER by artist_real_address ASC"; $result_write_mass = $db->prepare($query_write_mass); $result_write_mass->execute(); while ( list($receiver_id) = $result_write_mass->fetch(PDO::FETCH_BOTH) ) { $stmt = $db->prepare ("INSERT INTO inbox(folder_id, sender_id, sender_type, receiver_id, receiver_type, title, message_body, time, date

Which PDO SQL Query is faster in the long run and heavy data?

情到浓时终转凉″ 提交于 2019-12-24 09:28:36
问题 From a Table has over a million record , When i pull the data from it, I want to check if the requested data exists or not, So which path is more efficient and faster then the other? $Query = ' SELECT n.id FROM names n INNER JOIN ages a ON n.id = a.aid INNER JOIN regions r ON n.id = r.rid WHERE id = :id '; $stmt->prepare($Query); $stmt->execute(['id' => $id]); if ($stmt->rowCount() == 1) { $row = $stmt->fetch(); ...................... } else { exit(); } or $EXISTS = 'SELECT EXISTS ( SELECT n

Database query builder sometimes returns array instead of object running as a queued job

不打扰是莪最后的温柔 提交于 2019-12-24 09:13:30
问题 TL;DR I have queued jobs that sometimes seem to fail, because a regular database query (using Laravel's standard query builder) does not reliably return PHP objects as defined by the fetch mode in my config/database.php . It seemed to sometimes return an object or an array so somehow the fetch mode changes (and even changes back). Detailed question I'm querying an external database using Laravel's query builder. The fetch mode is set to return objects in config/database.php : 'fetch' => PDO: