I am having trouble with this code
$set = 'mycrazyemail#gmail.com'
$check_is_idk = $db->query("SELECT * FROM `ppl` WHERE `email` = '{$set}' AND `is` = 'idk' AND `belongs` = '{$id}'");
what is the problem?
You are missing a semi-colon at the end of the first line, it currently causes a parse error:
$set = 'mycrazyemail#gmail.com';
$check_is_idk = $db->query("SELECT * FROM `ppl` WHERE `email` = '{$set}' AND `is` = 'idk' AND `belongs` = '{$id}'");
Related
I have a string that looks like this
start
"contrib_11_FICO_Score = 0.7474262402579245 contrib_27_OtherPayments = -0.11397237107501418 contrib_20_LTV = 0.4209136780360599 contrib_0_AcctsOnUs = -0.195553721371136 contrib_19_InstallmentPayments = 0.08134999563389797 contrib_1_Amount = 0.07752028501333455 contrib_10_EstDebtToIncome = 0.19793275869285348 contrib_45_CVTE_ProductShortName.0 = 0.08545325753810393 contrib_21_LoanTerm = -0.20186524569828262 contrib_43_SatisfactoryLast2Yrs = 0.0710695727171011 contrib_50_WoE_ProductShortName.0 = -0.022073850549082376 contrib_31_PLCollectionTotal = 0.12617956675796796 contrib_40_RevBalToHighCredit = -0.5009070556076041 contrib_42_RevolvingPayments = 0.14787007118011708 contrib_39_RepoTotal = 0.002261663457841503 contrib_30_PLCollectionLast2yrs = 0.047241412208721086 contrib_15_InquiriesOnUs = -0.08118475273646548 contrib_17_InquiriesTotal = -0.23934745152247694 contrib_16_InquiriesToday = 0.06067597032236759 contrib_23_OilTE = -0.009115867521724635 contrib_14_InquiriesLast6mos = -0.01669536361883669 contrib_8_DTI = 0.40070958319864824 contrib_44_SatisfactoryTotal = -0.29471031930209096 contrib_22_Mortgage = -0.13973120155639737 contrib_3_AvgRevolvingBalance = -0.1339820646758586 contrib_41_RevolvingCount = 0.008316986809544236 contrib_32_Plus30Last2Yrs = 0.0315266336181764 contrib_29_OtherPublicTotal = 0.0025079738312499887 contrib_12_Inquiries30days = 0.08842218013671509 contrib_36_Plus90Last2Yrs = 0.03415210455083352 contrib_6_BankruptcyLast2yrs = 0.0037646391378712307 contrib_34_Plus60Last2Yrs = 0.014917255339436795 contrib_28_OtherPublicLast2yrs = 9.508765288605479E-4 contrib_bias = 0.7414680413223248"
and I'm trying to coerce it to a hash, like this.
end
{"contrib_11_FICO_Score"=>0.7474262402579245, "contrib_27_OtherPayments"=>-0.11397237107501418, "contrib_20_LTV"=>0.4209136780360599, "contrib_0_AcctsOnUs"=>-0.195553721371136, "contrib_19_InstallmentPayments"=>0.08134999563389797, "contrib_1_Amount"=>0.07752028501333455, "contrib_10_EstDebtToIncome"=>0.19793275869285348, "contrib_45_CVTE_ProductShortName"=>0.08545325753810393, "contrib_21_LoanTerm"=>-0.20186524569828262, "contrib_43_SatisfactoryLast2Yrs"=>0.0710695727171011, "contrib_50_WoE_ProductShortName"=>-0.022073850549082376, "contrib_31_PLCollectionTotal"=>0.12617956675796796, "contrib_40_RevBalToHighCredit"=>-0.5009070556076041, "contrib_42_RevolvingPayments"=>0.14787007118011708, "contrib_39_RepoTotal"=>0.002261663457841503, "contrib_30_PLCollectionLast2yrs"=>0.047241412208721086, "contrib_15_InquiriesOnUs"=>-0.08118475273646548, "contrib_17_InquiriesTotal"=>-0.23934745152247694, "contrib_16_InquiriesToday"=>0.06067597032236759, "contrib_23_OilTE"=>-0.009115867521724635, "contrib_14_InquiriesLast6mos"=>-0.01669536361883669, "contrib_8_DTI"=>0.40070958319864824, "contrib_44_SatisfactoryTotal"=>-0.29471031930209096, "contrib_22_Mortgage"=>-0.13973120155639737, "contrib_3_AvgRevolvingBalance"=>-0.1339820646758586, "contrib_41_RevolvingCount"=>0.008316986809544236, "contrib_32_Plus30Last2Yrs"=>0.0315266336181764, "contrib_29_OtherPublicTotal"=>0.0025079738312499887, "contrib_12_Inquiries30days"=>0.08842218013671509, "contrib_36_Plus90Last2Yrs"=>0.03415210455083352, "contrib_6_BankruptcyLast2yrs"=>0.0037646391378712307, "contrib_34_Plus60Last2Yrs"=>0.014917255339436795, "contrib_28_OtherPublicLast2yrs"=>9.508765288605479E-4, "contrib_bias"=>0.7414680413223248}
I can use gsub(" = ","=>")
.gsub(" contrib",","contrib").gsub("\","")
but I end up with
\"contrib
The backslashes prevent me from converting this to a hash. How can I strip the backslashes out? I would have thought that the escape character would work, but apparently not.
I also tried splitting the string on the space, but this gave me an array of strings and not a hash.
Thanks for any suggestions!
$this->db->select('SUM(status = In Stock)As In Stock,SUM(status = Allocated)AS Allocated,SUM(status = Decommission) as Decommission,SUM(status = In transit)AS In Transit');
// $this->db->from('assets');
$this->db->group_by("assettype,location");
$query = $this->db->get('assets');
Getting syntax error in the above query.
Kindly help
change
$this->db->select('SUM(status = "In Stock")As In_Stock,SUM(status = "Allocated")AS Allocated,SUM(status = "Decommission") as Decommission,SUM(status = "In transit")AS In_Transit');
What is the shortest and nicest way to have a hash table literal and instantly look up a value in it?
e.g. I was expecting something like
$city = #{"30328" = "Atlanta"; "60608" = "Chicago"} [$zipCode]
but that ends with:
Unexpected token '[$zipCode]' in expression or statement.
Just remove the space:
$city = #{"30328" = "Atlanta"; "60608" = "Chicago"}[$zipCode]
or
$city = #{"30328" = "Atlanta"; "60608" = "Chicago"}.$zipCode
I am trying to make a route in the ini file to match the following URLs, but I have been unsuccessful.
/add-announce.html
/add-announce-books-53.html
My route is this:
routes.add_announcement.type = "Zend_Controller_Router_Route_Regex"
routes.add_announcement.route = "/add-announce(-[a-zA-Z_]+)?(-[\d]+)?.html"
routes.add_announcement.defaults.module = announcement
routes.add_announcement.defaults.controller = frontend
routes.add_announcement.defaults.action = add
routes.announcements.defaults.catName = null
routes.announcements.defaults.catId = null
routes.add_announcement.map.catName = 1
routes.add_announcement.map.catId = 2
Maybe because your matches has '-' at the beginning?, Can you try with:
routes.add_announcement.route = "add-announce(?:-([a-zA-Z_]+))?(?:-([\d]+))?.html"
EDIT: I just found the error, you set the mapped values wrong:
routes.add_announcement.map.catName = 1
routes.add_announcement.map.catId = 2
instead you have to do it like this:
routes.add_announcement.map.1 = "catName"
routes.add_announcement.map.2 = "catId"
Also routes.announcements.defaults.catName shouldn't be routes.add_announcement.defaults.catName?
I have an Oracle function that returns a record set.
I introduced parameters to the Oracle function and this is causing the front-end code to go haywire.
Here's my front-end code.
OracleCommand od = oc.CreateCommand();
od.CommandType = System.Data.CommandType.Text;
od.CommandText = " select * from table(pkg_fetchPOInfo.getPORowsTable(:1,:2))";
//od.CommandText = "pkg_fetchPOInfo.getPORowsTable";
//od.CommandType = System.Data.CommandType.TableDirect;
OracleParameter op1 = new OracleParameter();
op1.ParameterName = "1";
op1.OracleDbType = OracleDbType.Varchar2;
op1.Direction = System.Data.ParameterDirection.Input;
op1.Size = 6;
op1.Value = strPONumber;
od.Parameters.Add(op1);
OracleParameter op2 = new OracleParameter();
op2.ParameterName = "2";
op2.OracleDbType = OracleDbType.Varchar2;
op2.Direction = System.Data.ParameterDirection.Input;
op2.Size = 3;
op2.Value = "US";
od.Parameters.Add(op2);
If I execute the query in the front-end SQLPLUS, I get a recordset.
This code works if I remove the parameters from the package and the front-end code.
select * from table(pkg_fetchPOInfo.getPORowsTable('1007446','US')); --works in SQLPLUS.
select * from table(pkg_fetchPOInfo.getPORowsTable()); --works in both places.
Am I assigning the parameters incorrectly?
Package Definition:
CREATE OR REPLACE
PACKAGE TESTP AS
function TESTPIPE(nr in number, nr2 in number) return varchartabletype pipelined;
END TESTP;
CREATE OR REPLACE
PACKAGE BODY TESTP AS
function TESTPIPE(nr in number, nr2 in number) return varchartabletype pipelined AS
CURSOR TESTPIPE_cur
IS
SELECT (level + 1) datam
FROM dual
connect by level < nr;
vtt varchartabletype ;
BEGIN
OPEN TESTPIPE_cur;
LOOP
FETCH testpipe_cur
BULK COLLECT INTO vtt LIMIT nr2;
FOR indx IN 1 .. vtt.COUNT
LOOP
Pipe Row ( vtt( indx ) ) ;
END LOOP;
EXIT WHEN testpipe_cur%NOTFOUND;
END LOOP;
END TESTPIPE;
END TESTP;
.NET Code:
public static void pipeTest()
{
String conString = GetConnectionString();
OracleConnection _conn = new OracleConnection(conString);
_conn.Open();
OracleCommand oCmd = new OracleCommand();
oCmd.CommandText = "begin open :crs for Select * from table(testp.testpipe(:nr,:nr2)); end;";
oCmd.CommandType = CommandType.Text ;
oCmd.Connection = _conn;
OracleParameter crs = new OracleParameter();
crs.OracleDbType = OracleDbType.RefCursor;
crs.Direction = ParameterDirection.Output;
crs.ParameterName = "crs";
oCmd.Parameters.Add(crs);
OracleParameter nr = new OracleParameter();
nr.OracleDbType = OracleDbType.Int64;
nr.Direction = ParameterDirection.Input ;
nr.ParameterName = "nr";
nr.Value = 25;
oCmd.Parameters.Add(nr);
OracleParameter nr2 = new OracleParameter();
nr2.OracleDbType = OracleDbType.Int64;
nr2.Direction = ParameterDirection.Input;
nr2.ParameterName = "nr2";
nr2.Value = 10;
oCmd.Parameters.Add(nr2);
using (OracleDataReader MyReader = oCmd.ExecuteReader())
{
int ColumnCount = MyReader.FieldCount;
// get the data and add the row
while (MyReader.Read())
{
String s = MyReader.GetOracleValue(0).ToString();
Console.WriteLine(string.Format("i={0}", s));
}
}
Console.ReadLine();
}