Solutions to several problems under pgsql

Source: Internet
Author: User
Tags sql error
Provides various official and user-released code examples and code reference. You are welcome to exchange and learn some problems that may occur when using pgsql in TP. A solution is provided for your reference.
1. The add () method cannot obtain the new primary key value. Modify row 134 of pgsql DRIVER: Db. Pgsql. class. php: list($last_insert_id) = pg_fetch_array($result,null,PGSQL_ASSOC);After testing, the value of the new ID is not assigned to $ last_insert_id, so it is changed $last_insert = pg_fetch_array($result,null,PGSQL_ASSOC);Change return: return $last_insert['insert_id'];2. Errors Caused by the keyword pgsql in SQL:
①: RBAC. class. php
User is the keyword of pgsql, And in this RBAC. class. the SQL statement in php contains a user, causing an SQL error. Therefore, change 'user' in the four SQL statements in this file to 'users ', then, the following rows of 214 rows, 227 rows, 240 rows, and 258 rows are added: $table['user']." as user,".Change $table['user']." as users,".②: The SQL statement in the view model is incorrect: SELECT COUNT(*) AS tp_count FROM tp_user UserOr because user is the keyword of pgsql;
Correction Method: Rename the user table to users or other
In short, when the PostgreSQL keyword appears in SQL, you should pay attention to it,
Keywords such as user and group cannot be used for data table names, field names, and field aliases.

In addition, the not null field in pgsql does NOT allow null values to be inserted, but in mysql, it is acceptable. Be sure to pay attention to this. If you are NOT careful, it will lead to an SQL syntax error.
Other bugs are being searched

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.