yii, i am getting sql error when using restful api - rest

I am writing restful API with Yii, but I am getting an SQL error in create function. My purpose is to add new data to the news table, but it asks me for the author_id. How can I do it without crushing the default create method?

Solution 1. Run this below query on mysql/phpmyadmin and restart server
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
Solution 2.
Open the my.ini or my.cnf file for editing (the file you have depends on whether you are running Windows or Linux).
Find the following line:
sql_mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Replace it with the line below:
If the line is not found, insert the line under the [mysqld] section (if there is no [mysqld] section, create it).
sql_mode= ""
Restart the MySQL service for the change to take effect.
If restarting is not a feasible option at the moment, you may log into the database server and execute the below command for the changes to take effect immediately. However, the change will be discarded the next time the MySQL service restarts unless the above process is performed.
set global sql_mode='';

Related

i am facing error about apex images loading

There is a problem with your environment because the Application Express files have not been loaded. Please verify that you have copied the images directory to your application server as instructed in the Installation Guide. In addition, please verify that your image prefix path is correct. Your current path is /i/ (it should contain both starting and ending forward slashes, such as the default /i/). Use the SQL script reset_image_prefix.sql if you need to change it.
Starting with Apex 18.1.x.x.x we should be instead putting CDN location as static path for images. Local path will not be supported any further.
Take a look at below announcement :
https://blogs.oracle.com/apex/announcing-oracle-apex-static-resources-on-oracle-content-delivery-network
CDN makes application faster.
Coming to problem you mentioned, can be easily resolved by performing below steps :
Locate reset_image_prefix.sql . It should be under 'apex/utilities'
change directory :
cd apex/utilities
Connect to DB and check what is image prefix
connect to SQL as SYS
SQL> set serveroutput on
SQL> begin
2 dbms_output.put_line(apex_200100.wwv_flow_image_prefix.g_image_prefix);
3
4 end;
5 /
It should list /i/ or any other location you may have configured with
Note: whenever you run the above command change to the correct APEX user (version), so for APEX 19.1 you use apex_190100.
4. Now, check CDN address. For example Apex 20.1.X.X.XX location is - https://static.oracle.com/cdn/apex/20.1.0.00.13/
Same can be checked from https://blogs.oracle.com/apex/announcing-oracle-apex-static-resources-on-oracle-content-delivery-network
5. Now, its time to run SQL (assuming you have APEX 19.2.0.X.XX version)
SQL> #reset_image_prefix.sql
Enter the Application Express image prefix [/i/] https://static.oracle.com/cdn/apex/19.2.0.00.18/
...Changing Application Express image prefix
NEW_IMAGE_PREFIX
------------------------------------------------
https://static.oracle.com/cdn/apex/19.2.0.00.18/
Go to http://your-host:your-port/ords/apex_admin
Problem should be resolved by now!

How to solve mysqli-mariaDB update fail, on a just inserted record

Hi: I run stateless (REST) web services written in PHP7.0 OO-style, under Apache. They use mysqli to connect to mariaDB instance on AWS. We discovered a db synchronization issue, and not sure where the problem is or how to solve it.
client call to service 1 will insert a record, and return the autogenerated primary key retrieved by $i_primary_key = $this->db->insert_id, post-successful insertion;
next client call will use that primary key to execute a service 2, which will UPDATE the record
since service 1 and 2 are separate https calls, they create their own connections, resources, etc.
The problem is that sometimes service 2 fails, complaining the record with such a primary key does not exist. Try again, or artificially delay calling service 2, after obtaining results from Service 1, and things work as they should.
How do I tell the mariaDB engine, or mysqli API to flush their cache after the insert? I am only guessing that the engine/connection in Service 1 has not yet made its resources available to its own internal server, hence other clients of the engine do not see the latest changes/data.
Any advice...?
Thanks
There is only one way for the "flush" not to have happened: If the INSERT is in a transaction that is not committed.
To investigate, find out what value of autocommit is being used in "service 1". If it is "on" (or "1"), then there is no way for the problem to occur.
If autocommit is off (0), the the code in service 1 failed to COMMIT the implicit transaction. That is a user error. I prefer, instead, to have explicit BEGIN...COMMIT statements.
I found this reading up on mariaDB:
https://mariadb.com/kb/en/library/server-system-variables/#flush
flush
Description: Usually, MariaDB writes changes to disk after each SQL statement, and the operating system handles synchronizing (flushing) it to disk. If set to ON, the server will synchronize all changes to disk after each statement.
Commandline: --flush
Scope: Global
Dynamic: Yes
Data Type: boolean
Default Value: OFF
...So I'm going to set it to ON. Once I have results I'll update confirming it working...

Wildfly - logging into one file

It seems my wildfly server produces separate log file for each day: like
server.log.2017-06-30 server.log.2017-07-06. Is it possible to make it logging into one (always same) file?
By default WildFly is configured to use a periodic-rotating-file-handler which rotates every day. If you don't want log rotation you can use a file-handler instead.
The following CLI commands will make the change to using a file-handler.
batch
/subsystem=logging/root-logger=ROOT:remove-handler(name=FILE)
/subsystem=logging/periodic-rotating-file-handler=FILE:remove
/subsystem=logging/file-handler=FILE:add(named-formatter=PATTERN, append=true, autoflush=true, file={relative-to=jboss.server.log.dir, path=server.log})
/subsystem=logging/root-logger=ROOT:add-handler(name=FILE)
run-batch
One attribute to note is the append attribute. I've set it to true so that you won't lose any log messages on a reboot or when this command is executed. If you're not concerned about losing log messages you could set it to false.

No error when stopping non existing service with chef

Im new to chef and trying to understand why this code does not return any error while if i do the same with 'start' i will get an error for such service does not exist.
service 'non-existing-service' do
action :stop
end
# chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* service[non-existing-service] action stop (up to date)
Don't know which plattform you are running on if you are running on Windows it should at least log
Chef::Log.debug "#{#new_resource} does not exist - nothing to do"
given that you have debug as log level.
You could argue this is the wrong behaviour, but if the service dose not exist it for sure isen't running.
Source code
https://github.com/chef/chef/blob/master/lib/chef/provider/service/windows.rb#L147
If you are getting one of the variants of the init.d provider, they default to getting the current status of a service by grepping the process table. Because Chef does its own idempotence checks internally before calling the provider's stop method, it would see there is no such process in the table and assume it was already stopped.

Configuring spring-xd to use oracle as job repository

I want to run spring xd with Oracle(11g) which i already have in my environment. Currently my first concern is the jobs UI (my database has existing data of job executions that were performed by spring-batch and i simply want to display the details of those executions).
i'm using spring-xd-1.0.0.M5. I followed the instructions in the reference guide and i changed application.yml to have the following:
spring:
datasource:
url: jdbc:oracle:oci:MY_USERNAME/MYPWD#//orarmydomain.com:1521/myservice
username: MY_USERNAME
password: MYPWD
driverClassName: oracle.jdbc.OracleDriver
profiles:
active: default,oracle
i modified also batch-jdbc.properties to have the database configuration similar to the above.
Yet, when i start xd-singlnode.bat (or either xd-admin.bat) it seems like it ignores my oracle configuration and still uses the default hsqldb.
what am i doing wrong?
Thanks
The likely reason is that we did not upgrade the windows .bat scripts to take advantage of the property overriding via xd-config.yml. If you go into the unix script for xd-singlenode you will see that when java is invoked there there is an option
-Dspring.config.location=$XD_CONFIG
you can for now hardcode your location of that file, use file: as the prefix.
Also, The UI right now is very primitive, you will not be able to see many details about the job execution. There are however many job related commands you can execute in the shell and there is only one gap regarding step execution information as compared to what is available via spring-batch-admin.
The issue to watch for this is https://jira.springsource.org/browse/XD-1209 and it is schedule for the next milestone release.
Let me know how it goes, thanks!
Cheers,
Mark