Search Results

Search found 144 results on 6 pages for 'hui jin'.

Page 5/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Propel: How the "Affected Rows" Returned from doUpdate is defined

    - by Ngu Soon Hui
    In propel there is this doUpdate function, that will return the numbers of affected rows by this query. The question is, if there is no need to update the row ( because the set value is already the same as the field value), will those rows counted as the affected row? Take for example, I have the following table: ID | Name | Books 1 | S1oon | Me 2 | S1oon | Me Let's assume that I write a ORM function of the equivalent of the following query: update `new table` set Books='Me' where Name='S1oon'; What will the doUpdate result return? Will it return 0 ( because all the Books column are already Me, hence there is no need to update), or will it be 2 ( because there are 2 rows that fulfill the where condition) ?

    Read the article

  • ToList()-- Does it Create a New List?

    - by Ngu Soon Hui
    Let's say I have a class public class MyObject { public int SimpleInt{get;set;} } And I have a List<MyObject>, and I ToList() it and then change one of the SimpleInt, will my change be propagated back to the original list. In other words, what would be the output of the following method? public void RunChangeList() { var objs = new List<MyObject>(){new MyObject(){SimpleInt=0}}; var whatInt = ChangeToList(objs ); } public int ChangeToList(List<MyObject> objects) { var objectList = objects.ToList(); objectList[0].SimpleInt=5; return objects[0].SimpleInt; } Why? P/S: I'm sorry if it seems obvious to find out. But I don't have compiler with me now...

    Read the article

  • Set Mime_type validation in Symfony

    - by Ngu Soon Hui
    I want to make sure that during file upload time, only the file of the format jpeg, png and gif are allowed. So the "File of type:" below in the screenshot must show jpeg, png and gif: I did the following for my validator in Symfony: $this->setValidator ( 'upload your filehere', new sfValidatorFile ( array ( 'required'=>true, 'mime_types' => array ('image/jpeg, image/png, image/gif' ) ) , array( 'mime_types'=> 'only jpeg' ) ) ); but when I click on the upload button, the files are not filtered accordingly; what did I do wrong? I also try $this->setValidator ( 'upload your filehere', new sfValidatorFile ( array ( 'required'=>true, 'mime_types' => 'image/jpeg, image/png, image/gif' ) , array( 'mime_types'=> 'only jpeg' ) ) ); But it doesn't work, too. I tried the following in my form class, but unfortunately it doesn't work as well: <?php class UploadCaseForm extends sfForm { public function configure() { $this->setWidgets ( array ('Documents' => new sfWidgetFormInputFile ( ) ) ); $this->widgetSchema->setNameFormat ( 'UploadCase[%s]' ); $this->validatorSchema ['Documents'] = new sfValidatorFile ( array ('mime_types' => 'web_images' ), array ('invalid' => 'Invalid file.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be of JPEG, PNG or GIF format.' ) ); } } ?> Here's the action code: public function executeIndex(sfWebRequest $request) { $this->form = new UploadCaseForm ( ); if ($this->getRequest ()->getMethod () == sfRequest::POST) { var_dump($request->getParameter('UploadCase')); } } Edit: The accepted answer is the answer, as far as the server side validation goes. If anyone wants a client side validation, i.e., filtering the type of file that can be uploaded even before the operation hits server, then maybe there is no reliable way to do it, because of browser's constraint.

    Read the article

  • Construct A Polygon Out of Union of Many Polygons

    - by Ngu Soon Hui
    Supposed that I have many polygons, what is the best algorithm to construct a polygon--maybe with holes- out of the union of all those polygons? For my purpose, you can imagine each piece of a polygon as a jigsaw puzzle piece, when you complete them you will get a nice picture. But the catch is that a small portion <5% of the jigsaw is missing, and you are still require to form a picture as complete as possible; that's the polygon-- maybe with holes-- that I want to form. My naive approach is to take two polygons, union them, and take another polygon, union it with the union of the two polygons, and repeat this process until every single piece is union. Then I will run through the union polygon list and check whether there are still some polygons can be combined, and I will repeat this process until a satisfactory result is achieved. But this seems to be like an extremely naive approach. I just wonder is there any other better algorithm?

    Read the article

  • Why Is It That Generics Constraint Can't Be Casted to Its Derived Type?

    - by Ngu Soon Hui
    It is quite puzzling to find out that Generics Constraint Can't Be Casted to Its Derived Type. Let's say I have the following code: public abstract class BaseClass { public int Version { get { return 1; } } public string FixString { get; set; } public BaseClass() { FixString = "hello"; } public virtual int GetBaseVersion() { return Version; } } public class DeriveClass: BaseClass { public new int Version { get { return 2; } } } And guess what, this method will return a compilation error: public void FreeConversion<T>(T baseClass) { var derivedMe = (DeriveClass)baseClass; } I would have to cast the baseClass to object first before I can cast it to DerivedClass. Seems to me pretty ugly. Why this is so?

    Read the article

  • Visual Studio 2008 Crystal Report Reference files.

    - by Jin
    Hi all, I am using Visual Studio 2008 and CR XI R2 for a web application built in silverlight. currently I am having a problem with showing a dynamic image on a crystal report. I was told that the reference file added in the project might be old version, so I replaced the reference files to be 11.5x version from 10.5x version. I removed all 10.5x dlls and then added 11.5x dlls, but I see 10.5x dlls are added instead. does anybody how to fix this problem? Please help. Thanks,

    Read the article

  • How to save esri map as a image file

    - by Jin
    Hi, I am using Silverlight 3 and I am trying to take a screenshot of esri map. I was able to take a screenshot and save as a file for silverlight controls, but when I try to access Esri map image, I get "Pixel access not allowed" error. I heard this is because of different domain (I am trying to get map image on the client side, and map image is not accessible at server side in my silverlight application). So I am trying to find a function from esri so that I can save the map image as a file. does anybody know how to do this? or any other way around?

    Read the article

  • Wrong effective-pom output

    - by Jin Kwon
    When calling help:effective-pom in some child modules position, the output prints wrong path. some url like .../${groupId}/${some_other_sibling's_artifactId}/... This is also make site deploy wrong. Can anybody help?

    Read the article

  • .trim() in javascript not working in IE

    - by Jin Yong
    I tired to apply .trim() in javascript for one of my code. it's working fine under mozilla, but error display once I tried in IE8, does anyone know what is going on here? anyway I can make it work in IE? code: var ID = document.getElementByID('rep_id').value.trim(); error display: Message: Object doesn't support this property or method Line: 604 Char: 2 Code: 0 URI: http://test.localhost/test.js

    Read the article

  • Multiple databases support in Symfony

    - by Ngu Soon Hui
    I am using Propel as my DAL for my Symfony project. I can't seem to get my application to work across two or more databases. Here's my schema.yml: db1: lkp_User: pk_User: { type: integer, required: true, primaryKey: true, autoIncrement: true } UserName: { type: varchar(45), required: true } Password: longvarchar _uniques: Unique: [ UserName ] db2: tesco: Id: { type: integer, required: true, primaryKey: true, autoIncrement: true } Name: { type: varchar(45), required: true } Description: longvarchar And here's the databases.yml: dev: db1: param: classname: DebugPDO test: db1: param: classname: DebugPDO all: db1: class: sfPropelDatabase param: classname: PropelPDO dsn: 'mysql:dbname=bpodb;host=localhost' #where the db is located username: root password: #pass encoding: utf8 persistent: true pooling: true db2: class: sfPropelDatabase param: classname: PropelPDO dsn: 'mysql:dbname=mystore2;host=localhost' #where the db is located username: root password: #pass encoding: utf8 persistent: true pooling: true When I call php symfony propel-build-model, only db1 is generated, db2 is not. Any idea how to fix this problem?

    Read the article

  • Algorithm to Group All the Cycles Together

    - by Ngu Soon Hui
    I have a lot of cycles ( indicated by numeric values, for example, 1-2-3-4 corresponds to a cycle, with 4 edges, edge 1 is {1:2}, edge 2 is {2:3}, edge 3 is {3,4}, edge 4 is {4,1}, and so on). A cycle is said to be connected to another cycle if they share one and only one edge. For example, let's say I have two cycles 1-2-3-4 and 5-6-7-8, then there are two cycle groups because these two cycles are not connecting to each other. If I have two cycles 1-2-3-4 and 3-4-5-6, then I have only one cycle group because these two cycles share the same edge. What is the most efficient way to find all the cycle groups?

    Read the article

  • Debug.Assert Appears in Release Mode

    - by Ngu Soon Hui
    We all know that Debug.Assert will not be compiled into the dlls when compiled in release mode. But for some reason Debug.Assert did appear in the release version of a component I wrote. I suspect that I might have mess up my csproject setting. Any idea why Debug.Assert appears in release mode? P/S: I have double checked to make sure that I was really compiling in release mode before asking this question.

    Read the article

  • Upload files in Google App Engine

    - by Ngu Soon Hui
    I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through db.TextProperty and db.BlobProperty. I'll be glad anyone can provide code sample ( both the client and the server side) on how this can be done, thanks

    Read the article

  • android: ending activity from tab

    - by Jin
    I have 3 classes, let's call them 1, 2, and 3. Class 1 extends TabActivity and organizes the whole tab thing, Class 2 and 3 are just two separate tabs each with some lines of text. I call Class 1 from another activity using startActivityForResult. I then added an optionsMenu in class 2, and when user clicks the optionMenu, the following code is carried out: @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { Intent i = new Intent(); switch(item.getItemId()) { case Result.NEXT_ID: i.putExtra(Result.PAGE_REQUEST, NEXT); setResult(RESULT_OK, i); finish(); break; case Result.PREV_ID: i.putExtra(Result.PAGE_REQUEST, PREV); setResult(RESULT_OK, i); finish(); } return super.onMenuItemSelected(featureId, item); } In my parent class (the class that called 1 to begin with), in its onActivityResult function, I want to get the data from the extras. However, the intent is always null, and I can't figure out why. When I call finish() on class 2, is it calling some other function in class 1? Do I have to transfer the intent data somehow?

    Read the article

  • Declare a Dictionary inside a static class

    - by Ngu Soon Hui
    How to declare a static dictionary object inside a static class? I tried public static class ErrorCode { public const IDictionary<string , string > ErrorCodeDic =new Dictionary<string, string>() { {"1","User name or password problem"} }; } But the compiler complains that "A const field of a reference type other than string can only be initialized with null".

    Read the article

  • How to copy a ram_base file to disk efficiently

    - by Hui Jin
    I want to copy a large a ram-based file (located at /dev/shm direcotry) to local disk, is there some way for an efficient copy instead of read char one by one or create another piece memory? I can use only C language here. Is there anyway that I can put the memory file directly to disk? Thanks!

    Read the article

  • Get return values from a stored procedure in c# (login process)

    - by Jin
    Hi all, I am trying to use a Stored Procedure which takes two parameters (login, pw) and returns the user info. If I execute the SP manually, I get Session_UID User_Group_Name Sys_User_Name ------------------------------------ -------------------------------------------------- - NULL Administrators NTMSAdmin No rows affected. (1 row(s) returned) @RETURN_VALUE = 0 Finished running [dbo].[p_SYS_Login]. But with the code below, I only get the return value. do you know how to get the other values shown above like Session_UID, User_Group_Name, and Sys_User_Name ? if you see the commented part below code. I tried to add some output parameters but it doesn't work with incorrect number of parameters error. string strConnection = Settings.Default.ConnectionString; using (SqlConnection conn = new SqlConnection(strConnection)) { using (SqlCommand cmd = new SqlCommand()) { SqlDataReader rdr = null; cmd.Connection = conn; cmd.CommandText = "p_SYS_Login"; //cmd.CommandText = "p_sys_Select_User_Group"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter paramReturnValue = new SqlParameter(); paramReturnValue.ParameterName = "@RETURN_VALUE"; paramReturnValue.SqlDbType = SqlDbType.Int; paramReturnValue.SourceColumn = null; paramReturnValue.Direction = ParameterDirection.ReturnValue; //SqlParameter paramGroupName = new SqlParameter("@User_Group_Name", SqlDbType.VarChar, 50); //paramGroupName.Direction = ParameterDirection.Output; //SqlParameter paramUserName = new SqlParameter("@Sys_User_Name", SqlDbType.VarChar, 50); //paramUserName.Direction = ParameterDirection.Output; cmd.Parameters.Add(paramReturnValue); //cmd.Parameters.Add(paramGroupName); //cmd.Parameters.Add(paramUserName); cmd.Parameters.AddWithValue("@Sys_Login", textUserID.Text); cmd.Parameters.AddWithValue("@Sys_Password", textPassword.Text); try { conn.Open(); object result = cmd.ExecuteNonQuery(); int returnValue = (int)cmd.Parameters["@RETURN_VALUE"].Value; if (returnValue == 0) { Hide(); Program.MapForm.Show(); } else if (returnValue == 1) { MessageBox.Show("The username or password you entered is incorrect", "NTMS Login", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (returnValue == 2) { MessageBox.Show("This account is disabled", "NTMS Login", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Database error. Please contact administrator", "NTMS Login", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { string message = ex.Message; string caption = "MAVIS Exception"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show( message, caption, buttons, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } } } Thanks for your help.

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >